Without the 1M ohm resistor, the mosfet would stay open even if the switch was opened again.
You want to use a 1M ohm resistor in order to create as little current as possible
(12V/1 000 000R = 0.000012A)
I found it difficult to understand the difference in usage between a BJT and a MOSFET, I hope this will help those with the same issue.
Have fun experimenting!