If you switch your engine off and it continues to run or splutter then you are experiencing run-on or dieseling.
This can caused by a number of things:
1) Too fast an idle speed.
2) Too rich fuel mixture. (Long-term causing carbon build up which glows hot and ignites fuel after the ignition circuit has switched off)
3) Too lean a fuel mixture at top end from incorrect jetting or airleak, casuing the engine to overheat.
The fuel/air mixture could be heated to the point that it self-ignites, causing the diesel run-on effect.
4) Timing is out. The timing itself won’t cause the run on as the ignition is switched off when the run in occurs. However timing too far advanced can cause an overheating engine which can attribute to over-run.
5) Lower octane fuel could aggravate the problem, because it will self-ignite quicker than a higher octane fuel. But it alone won’t cause the problem.
6) If you run a single or twin carb setup that has electromagnetic idle air cutoffs (usually solex only) it is meant to also keep this from happening by cutting off the idle air circuit when the ignition switch is turned off. Check these are working.
7) Sparkplugs have a temperature range. Are you running the right ones for your engine spec? Also are they clean and gapped correctly?
As with any running issue I always advise to make any adjustments logically. 1) Valves 2) Timing and ignition system check (point and plug gap and clean) 3) Adjust carburettor / inspect fuel system.