In some newer cars there's a low oil pressure sensor that shows a low oil pressure light on your dash and if the low oil pressure gets too low then the sensor sends information to the vehicles computer telling it to shut the engine down due to low oil pressure to prevent engine damage.
So if your engine oil is low you should top it off and you should add oil anyway to prevent damage to the engine.
Other things that could be causing your cars engine to stall are low fuel pressure, bad or clogged fuel injectors, clogged fuel filter, bad spark plugs, bad ignition coils and a whole list of other things could cause your engine to stall.