In tank fuel pumps do run continuously as long as the engine is running.
After the engine is shut off the fuel pump should also shut off but as long as the engine is running the in tank fuel pump also remains running to keep the engine supplied with fuel.
A fuel pump runs all the time but only while the engine is running.
When you turn the key on to start the engine the fuel pump will run for a few seconds and then shut off until you turn the key again to begin starting the engine.
The fuel pump comes back on when you start the engine and remains on once the engine is running.
If the fuel pump shut off while the engine was running then the engine would die and shut off because of no fuel getting to the engine.
The fuel pump is intended to run all the time while the engine is running and then when you turn the engine off and the key off the fuel pump should shut off along with the engine.
If the fuel pump remains running with the engine shut off then you either have an electrical problem or a bad fuel pump relay.
On modern vehicles the fuel pump runs for a couple of seconds when the ignition is first switched on, it then stops but begins to run the moment the engine starts and constantly runs while the engine is running,.
And if the engine stops for any reason with the ignition still in the on position the fuel pump will also stop.