Nonlinear stability of magnetohydrodynamic generators