Similar to problem I had. Z22SE. Would start from cold and run perfectly until I stopped for a short time. Then, when re-started, would run fine or a short time then start to misfire badly. Same symptoms you describe.
After replacing spark plugs, crankshaft sensor, coolant water temperature sensor, removing EGR, problem persisted until the ignition coil pack was replaced with a second hand part from scrapyard. No more misfiring.. Second hand cost about 25 GBP which price seems to be the norm in Scotland.