When there is trash floating or not floating around in the gas tank it can take a few minutes for it to work it’s way to the pickup tube. Then the engine begins to starve for fuel and eventually dies. Once the fuel pump quits pumping the suction releases and the crud, whatever it is, floats/moves away from the pickup tube and the pump will be able to pull fuel through the line again. The engine will then start and run normally until the process repeats itself.