The fuel cut off works by either an inertia cut off switch that is usually mounted on the bulkhead area and deploys in the event of a crash and is reset by pressing the rubber button down.
Alternatively, the crankshaft sensor generates a signal to show the engine is rotating and if it is not then it cuts the fuel.