Engine occasionally shutting off when car is idle

Hi everyone, so I have a Jeep Grand Cherokee 2001 with about 150,000 miles. About every other day my car will shut off while I’m stopped at a light, stop sign, etc. The strange thing is that the radio and lights (stuff controlled by the battery I assume) does not turn off with the engine. It seems the frequency with which this happens has stayed about the same, and I haven’t been too worried until yesterday when I went to start my car and it would not start. It just kept revving and seemed like it was very close to starting. I opened the hood and saw a lot of corrosion on the battery and luckily I had a coke in the car. After pouring some coke and wiping away the corrosion, the car started up. I have had no problems since I did this yesterday. But like I said, my car engine seems to turn off without warning so it could happen next time I drive. I was wondering if anyone thinks the two problems could be linked, that is the corrosion on the battery could have caused both the car not starting and the engine shutting off when the car is idling. I took to a mechanic about a month ago and they couldn’t find anything wrong with it and, of course, it didn’t shut off when they drove it. Any help would be great!! Thanks!


And I forgot to mention, when it does shut off it will always turn back on when I start the ignition, so at least I don’t get stranded while on the road :confused: