I purchased a used 2002 Jeep Grand Cherokee 4.0 with 130,000 miles and almost immediately started noticing strange things happening. When I turned the dome light on, the radio would turn off and not come back on until it felt like it, and the cruise control didn't work. I figured I had some bugs to work on, then it started to stall, and I realized I had other problems. It started stalling at highway speeds and just idling in my driveway, and would not start after it stalled for quite some time, almost like it had no gas. I took the advice on the forums and changed both the cam and the crank sensor. Neither of those things turned out to be the problem. Then I read a post about the computer screws being too long, which is what led me to the root of my problem.
Upon taking the computer out of the motor compartment firewall of my jeep, I used a torque screwdriver to loosen the four screws that hold the cover on the computer. I noticed a white powdery corrosion all over the aluminum computer housing, which had apparently spread to the inside of the computer housing. The computer is a thin membraned printed circuit board which is actually part of one half of the housing, so when the corrosion spread into the computer, it spread under the board, curling it, and popping off resistors that are essential to the vehicles functions.
Check your computer for white powder along seams or edges and if you find any, purchase a new computer for your vehicle. This should help with your stalling problems. I found an exact match for mine online for about 200, the dealer wants around 600.