Weird car wont stay running sometimes

So I have a weird problem, when I switch the ignition on the car starts up however as soon as I let go of the key SOMETIMES the engine will shut off. Sometimes the car will stay running no problem. When the engine shuts off i have to switch ignition to on to start car, hold the key in on position and very slightly give gas for a few seconds. Then when I let go of the key, whilst still having gas pressed, car will stay running. At this point when letting the key go rarely it tries to shut off for half a second the engine will shut off/skip but then stay running. Some background, this problem only started happening when 2 weeks ago I switched the ignition on and the engine was shaking a bit so i gave it some gas but gave too much and the engine shook a lot then shut of. When trying to switch back on it wouldnt start, it would crank but no start. I left it till the next day and it did start after some cranking but then this problem started. It starts first stime straight away now. Also around 3 weeks ago i changed the ignition housing and switch, could it be to do with the electrics in the control module under the steering wheel? No engine light, no fault codes. Very perplexed. Golf 1.9 TDI 2007

While reading your post, I was thinking a problem with your ignition switch. Sounds like you’ve already touched on that, though. Hmm.

The problem previously with it was the key wouldn’t turn beyond the steering lock position. So I changed the ignition switch housing. I’m wondering if it’s something I didn’t put connect back properly, but after I changed the switch nd lock housing there wasn’t any problem with the car until that day I gave it too much gas.

So to be clear… did you change the actual ignition switch, or just the plastic housing around the switch, behind the steering wheel?

From your description, it sounds to me like you didn’t actually change out the ignition switch. The housing doesn’t have anything to do with switch problems.

But I could be misunderstanding you…

Since it’s a diesel you might consider a faulty fuel shut-off solenoid or an erratic power supply to that solenoid.
Once a diesel is running the only way to stop it is to shut the fuel supply off and that is what the solenoid is for. It should have power to it all the time the engine is running. Should be mounted on the injection pump. It’s a cheap easy fix if that is the cause.

I changed the whole metal ignition steering lock which the lock barrel cylinder sits in. The new steering lock housing came with a new ignition switch. This: