We present Bayesian Analysis of Galaxies for Physical Inference and Parameter EStimation, or B, a new P tool which can be used to rapidly generate complex model galaxy spectra and to fit these to arbitrary combinations of spectroscopic and photometric data using the M N nested sampling algorithm. We extensively test our ability to recover realistic star-formation histories (SFHs) by fitting mock observations of quiescent galaxies from the M simulation. We then perform a detailed analysis of the SFHs of a sample of 9289 quiescent galaxies from UltraVISTA with stellar masses, M * > 10 10 M and redshifts 0.25 < z < 3.75. The majority of our sample exhibit SFHs which rise gradually then quench relatively rapidly, over 1−2 Gyr. This behaviour is consistent with recent cosmological hydrodynamic simulations, where AGN-driven feedback in the low-accretion (jet) mode is the dominant quenching mechanism. At z > 1 we also find a class of objects with SFHs which rise and fall very rapidly, with quenching timescales of < 1 Gyr, consistent with quasar-mode AGN feedback. Finally, at z < 1 we find a population with SFHs which quench more slowly than they rise, over > 3 Gyr, which we speculate to be the result of diminishing overall cosmic gas supply. We confirm the mass-accelerated evolution (downsizing) trend, and a trend towards more rapid quenching at higher stellar masses. However, our results suggest that the latter is a natural consequence of mass-accelerated evolution, rather than a change in quenching physics with stellar mass. We find 61 ± 8 per cent of z > 1.5 massive quenched galaxies undergo significant further evolution by z = 0.5. Bis available at bagpipes.readthedocs.io.