I suggest a (BIG) back emf diode, provided it's installed at the DC section. During normal operation, the diode is reverse biased and does nothing. When you open the magnet, the back emf will forward bias the diode and deal with the inductive effects that I think you're experiencing.
This will cop a bit of energy - think beer can as opposed to pencil when it comes to sizing it. And DON'T do this if you're not sure it's DC!!