In some astrophysical flows known to be linearly stable, finite-amplitude perturbations with favourable spatial structure can nonlinearly trigger a transition from a non-magnetic, non-turbulent state to self-sustained dynamo action and turbulence. Such transitions are suspected to significantly impact spin-down in radiative stellar layers or accretion rates in stellar discs. I will first present numerical examples of nonlinearly-triggered Tayler-Spruit dynamos in a spherical shell and zero-net-flux MRI dynamos in a quasi-Keplerian plane flow. I will then discuss how optimal control can identify stable, nontrivial (M)HD equilibria without requiring prior knowledge of the transition mechanisms.