Feedback from energy liberated by gas accretion onto black holes (BHs) is an attractive mechanism to explain the exponential cut-off at the massive end of the galaxy stellar mass function (SMF). Semi-analytic models of galaxy formation in which this form of feedback is assumed to suppress cooling in haloes where the gas cooling time is large compared to the dynamical time do indeed achieve a good match to the observed SMF. Furthermore, hydrodynamic simulations of individual halos in which gas is assumed to accrete onto the central BH at the Bondi rate have shown that a self-regulating regime is established in which the BH grows just enough to liberate an amount of energy comparable to the thermal energy of the halo. However, this process is efficient at suppressing the growth not only of massive galaxies but also of galaxies like the Milky Way, leading to disagreement with the observed SMF. The Bondi accretion rate, however, is inappropriate when the accreting material has angular momentum. We present an improved accretion model that takes into account the circularisation and subsequent viscous transport of infalling material and include it as a "subgrid" model in hydrodynamic simulations of the evolution of halos with a wide range of masses. The resulting accretion rates are generally low in low mass (\lsim 10^{11.5} \msun) halos, but show outbursts of Eddington-limited accretion during galaxy mergers. During outbursts these objects strongly resemble quasars. In higher mass haloes, gas accretion occurs continuously, typically at 10 % of the Eddington rate, which is conducive to the formation of radio jets. The resulting dependence of the accretion behaviour on halo mass induces a break in the relation between galaxy stellar mass and halo mass in these simulations that matches observations