Massive early-type galaxies have higher metallicities and higher ratios of $alpha$ elements to iron than their less massive counterparts. Reproducing these correlations has long been a problem for hierarchical galaxy formation theory, both in semi-analytic models and cosmological hydrodynamic simulations. We show that a simulation in which gas cooling in massive dark haloes is quenched by radio-mode active galactic nuclei (AGNs) feedback naturally reproduces the observed trend between $alpha$/Fe and the velocity dispersion of galaxies, $sigma$. The quenching occurs earlier for more massive galaxies. Consequently, these galaxies complete their star formation before $alpha$/Fe is diluted by the contribution from type Ia supernovae. For galaxies more massive than $sim 10^{11}~M_odot$ whose $alpha$/Fe correlates positively with stellar mass, we find an inversely correlated mass-metallicity relation. This is a common problem in simulations in which star formation in massive galaxies is quenched either by quasar- or radio-mode AGN feedback. The early suppression of gas cooling in progenitors of massive galaxies prevents them from recapturing enriched gas ejected as winds. Simultaneously reproducing the [$alpha$/Fe]-$sigma$ relation and the mass-metallicity relation is, thus, difficult in the current framework of galaxy formation.