We show how the interplay between active galactic nuclei (AGN) and merger history determines whether a galaxy quenches star formation at high redshift. We first simulate, in a full cosmological context, a galaxy of total dynamical mass $10^{12}\,M_{\odot}$ at $z=2$. The...