After driving for more than 20 miles the engine stop running or cut off.
on 2005 Mazda Mazda3

Engine will not start till it is cools off. Then, it start on and off continually.
What could be the problem? The Engine turns off when it is hot. The fan is running but the engine still turns off.

Asked by for the 2005 Mazda Mazda3
Check for codes and advice us so we can be of more help. From what you say it could be related to a bad sensor of some sort, or eleactrical issue.