This depends on whether the vehicle is gas or diesel fuel. A gasoline powered vehicle can have this fault if the fuel pump is failing. This causes the engine to "cut out" at high RPMs, when more fuel is required. It can also fail if the ignition coil is failing. When the coil is failing it tends to overheat during prolonged driving and cause the engine to stall. Diesel vehicles can either be caused by a failing fuel pump, water in the fuel filter that needs to be drained or a break in the wire powering the injector pump solenoid. If you happen to own a Nissan Serena with a SD20 engine, watch this spot. Mine has just started to exhibit those symptoms and I will be sure to update this answer as soon as the dealer has finished checking mine.
Overheating ? - Check radiator for water and coolant, and engine for enough oil and not old burnt oil
Died while driving? Alternator
there is humidity in your engine control module
if it won't start up again chances are it's probably your fuel pump
check your timing belt
it may be the o2 scensor
when i am driving my toyato 2001 Eaco stops running, it will start back up
engine rubber mounts or timin out
Stalling while driving may be caused by a collapsing or kinked neoprene fuel line.
Check timing belt
The reason your 2001 Hyundai Sonata lost all power while you were driving and stalled and won't start again is either the battery or the alternator. If you have no power you most likely have an alternator problem.
The year, make, model and engine info would help.