If the engine just shuts off like a flip of the switch then the common heat related component that fails is the crank sensor but electrical failures will almost always set an error code but not running out of gas which means fuel pump.
After the engine dies listen for the high pitched whine...