the pump when engine is running will also always run.
this provides a steady stream of fuel to the rail and injectors. whats not used by the injectors is returned to the tank from the regulator side.
the pump under normal conditions should do the following...
key on, ignition on, NOT cranking -> pump primes for 1-2 seconds, then turns off if no crank signal is detected
key on, ignition on, starter button pressed -> pump will prime and remain on if engine starts and runs. if engine fails to start, pump will stop running for the 1-2 seconds of 'priming' duration.
key on, ignition on, engine running then dies -> pump will run for the 'prime' period duration, then turn off until either ignition is cycled or starter button is pressed to trigger a crank signal again