Causes of over-voltage at the gate when a MOSFET is being switched
What you need is called a "flyback diode". Do NOT use a zener diode for that as these are generally too slow ! What you want is a diode connected in reverse across the motor, like this:



Ignore that here they're using 5V and an NPN transistor instead of 12V and a MOSFET, the same principles still apply.

Note that the diode appears to do nothing when the transistor is conducting or not. That is correct, the diode does nothing in those cases.

But when the motor is ON and you switch OFF the transistor, there will be a lot of magnetic and mechanical energy still in the motor present. That energy will try to escape and generate a high and negative voltage across it's terminals. This voltage can be enough to damage your MOSFET ! But if you have placed the flyback diode it will start to conduct and short this high voltage thereby protecting your MOSFET.

You can use almost any 1 A diode as a flyback diode. The 1N4001 - 1N4007 series diodes are cheap and suitable for this purpose.