Star-forming galaxies can in principle be transformed into passive systems by a multitude of processes that quench star formation, such as the halting of gas accretion (starvation) or the rapid removal of gas in AGN-driven outflows. However, it remains unclear which processes are the most significant, primary drivers of the SF-passive bimodality. We address this key issue in galaxy evolution by studying the chemical properties of 80 000 local galaxies in Sloan Digital Sky Survey Data Release 7. In order to distinguish between different quenching mechanisms, we analyse the stellar metallicities of star-forming, green valley, and passive galaxies. We find that the significant difference in stellar metallicity between passive galaxies and their star-forming progenitors implies that for galaxies at all masses, quenching must have involved an extended phase of starvation. However, some form of gas ejection also has to be introduced into our models to best match the observed properties of local passive galaxies, indicating that, while starvation is likely to be the prerequisite for quenching, it is the combination of starvation and outflows that is responsible for quenching the majority of galaxies. Closed-box models indicate that the duration of the quenching phase is 2–3 Gyr, with an e-folding time of 2–4 Gyr, after which further star formation is prevented by an ejective/heating mode. Alternatively, leaky-box models find a longer duration for the quenching phase of 5–7 Gyr and an e-folding time of ∼1 Gyr, with outflows becoming increasingly important with decreasing stellar mass. Finally, our analysis of local green valley galaxies indicates that quenching is slower in the local Universe than at high redshift.