The dark nemesis of galaxy formation : why hot haloes trigger black hole growth and bring star formation to an end