When switching inductive loads you have to put a diode in antiparallel with the load, else you risk blowing up your transistor due to inductive spiking. This video explains it all. Bonus: Here is an online circuit simulator that you can use to simulate inductive spiking behaviour.
