Thermal stability of superconducting magnets: static criteria