Massive galaxies today typically are not forming stars despite being surrounded by hot gaseous haloes with short central cooling times. This likely owes to some form of ‘quenching feedback’ such as merger-driven quasar activity or radio jets emerging from central black holes. Here we implement heuristic prescriptions for these phenomena on-the-fly within cosmological hydrodynamic simulations. We constrain them by comparing to observed luminosity functions and colour–magnitude diagrams from the SDSS. We find that quenching from mergers alone does not produce a realistic red sequence, because 1–2 Gyr after a merger the remnant accretes new fuel and star formation re-ignites. In contrast, quenching by continuously adding thermal energy to hot gaseous haloes quantitatively matches the red galaxy luminosity function and produces a reasonable red sequence. Small discrepancies remain – a shallow red-sequence slope suggests that our models underestimate metal production or retention in massive red galaxies, while a deficit of massive blue galaxies may reflect the fact that observed heating is intermittent rather than continuous. Overall, injection of energy into hot halo gas appears to be a necessary and sufficient condition to broadly produce red and dead massive galaxies as observed.