Do you mean random stalling and then the engine doesn't even turn over (crank) Or do you mean random stalling and the engine cranks, but doesn't start?
If it stalls, cranks but doesn't start, a common failure on the 4.0 that can be responsible for both symptoms is the crankshaft position sensor.