Excess heat or excess compression (carbonized combustion chambers) can cause the engine to diesel (i.e., ignite fuel without spark). Excess idle speed can exacerbate the problem. Higher octane can ameliorate. When the switch is off, timing is no longer relevant (no spark). If mistiming is enough to contribute to excess heat it could contribute to dieseling. Fuel mixture on the rich side will help cool the combustion chambers, lean to "hotten" chambers. Less likely, wrong plugs can store high heat and set off compressed fuel.
Bob