Trying to see how the motor works in circuit. Don't know if it works here is same as in the real world.
Added diode so motor would have a path to release its charge of voltage and or current, whichever.
With switch off the motor releases its energy thru diode.