Start by power washing your entire engine copmpartment, especially around the battery and the space between the radiator and the A/C condenser. This will improve electrical grounds.Abad or flaky ground can be a nasty thing to uncover! Locate and clean the idle air control valve and throttle plate with Gum-out spray. This will improve idling performance and improve fuel mileage. Make sure that you don't have any trouble codes in your CPU memory. This particular problem sounds like a crank sensor that goes out of specification when the engine is too hot. Good Luck!!