Here's how it works:
* ECM Control: The ECM is the brain of the engine. When the ignition key is turned to the "off" position, the ECM receives a signal. It then cuts off the electrical signal to the fuel injectors. Without fuel being injected into the cylinders, the engine can't continue running. Simultaneously or shortly after, the ECM also cuts off the spark to the spark plugs.
* Fuel Pump: The fuel pump itself doesn't automatically shut off the instant the key is turned off. It continues running for a few seconds to allow the fuel lines to depressurize. Then, a relay controlled by the ECM cuts power to the fuel pump.
In essence, it's the ECM that orchestrates the shutdown by cutting off both the fuel supply (via the injectors and eventually the fuel pump) and the spark (via the ignition system). The fuel pump and spark plugs are *components involved* but the *method* is via ECM control signals.