The year, make, model and engine info would help but a serious vacuum leak could do that.
Dirty fuel filter
to much of it can stop our system
There are several reasons an engine may stall while driving, here are three.The fuel tank is empty and the engine is starved of fuel.Not enough power to climb a hill causing a stall.Faulty or damp electronics on a petrol engine can also cause a stall.
What causes a 1997 Pontiac sunfire gt with a 2.4 liter engine to stall when stopped at a light
possible bad TPS, IAC, or ECT sensors
The crank sensor probably needs to be replaced.
More info such as the year and engine size would help.
Need to know the year and make, It would help answer.
Removing the oil cap with the engine running causes a vacuum leak in the positive crankcase ventilation. This causes too much air to enter the cylinders at once, which results in a stalling engine.
The TPS (throttle position sensor) has gone bad on your throttle body.
Check for vaccuum leaks this could be your problem.
your engine will stall. When you try to restart the engine, it will stutter and stall again.