Magnetic catalysis of stability of quark matter in the Nambu-Jona-Lasinio model