Magnetic field stability of superconducting magnets