Why would car stop after driving for 3 to 5 miles not overheating but starts after it cools?

usually this is from an electric component heating up and then works again when it cool. such as, ignition module, crank sensor, cam sensor, coil, or even ecm.