No spark vertical cylinder pantah

Puzzling over a strange fault on a 350 pantah engine. There is no spark on the upright cylinder while running - BUT the plug does spark momentarily just as the engine is turned off. This happens whether turned off at the key, or the bar switch. Any ideas what’s wrong??