Magnetic-field-induced cavity protection for intersubband polaritons