The fundamental metallicity relation (FMR) of galaxies is a 3D relation between the gas-phase metallicity, stellar mass and star-formation rate (SFR). It has been studied so far only for galaxies identified as star-forming (SF) on the BPT diagrams (BPT-SF), but not for galaxies with LI(N)ER/AGN classification (BPT-non-SF), mainly due to the lack of diagnostics for estimating their gas-phase metallicities in the latter cases. We extend the FMR to BPT-non-SF galaxies. To this end, we exploit the recent nebular line empirical calibrations derived specifically for galaxies classified as non-SF in the BPT diagrams. Moreover, we study an alternative representation of the FMR where we consider the offsets in metallicity and SFR with respect to Main Sequence (MS) galaxies. We find that galaxies with SFR higher than the MS are more metal-poor than their counterparts on the MS, which is interpreted in terms of gas accretion, boosting star formation and diluting the metallicity. Low-mass galaxies below the MS (i.e. towards quiescence) have metallicities higher than their MS counterparts, which is interpreted in terms of starvation, (i.e. suppression of fresh gas supply) hampering star formation and reducing the dilution effect, hence resulting in a higher level of internal chemical enrichment. Massive galaxies below the MS have gas metallicity much closer to their MS counterparts and much lower than expected from their stellar metallicities; this result suggests a scenario where massive nearly-quiescent galaxies with LI(N)ER-like nebular emission have recently accreted gas from the circum/intergalactic medium.