A diesel engine is stopped by cutting off its fuel. That's done in one
of two ways. You can manually press the STOP lever on the throttle
linkage or turn the key to OFF. When you turn the key to OFF vacuum is
applied to a small bellows inside the injection pump, the "shut down
device," which pulls the fuel rack to its OFF position and the engine,
deprived of fuel, stops.
Remember this, for a vacuum leak (anywhere) or worn out shut down device
will allow the engine to keep running no matter what you do with the key
and until you open the hood and press the STOP lever which will always
stop the engine. As a new diesel driver you should know how to manually
stop the engine. Try it, you won't hurt anything.
As a matter of interest, a diesel can "runaway" that is, run
uncontrolled to the point of self destruction if, but only if, its lube
oil is somehow sucked into its intake manifold. The engine, being an oil
engine runs on its lube oil rather than its fuel. I've heard of this
happening with stationary engines when their turbos' seals failed but
haven't heard that happen with our engines.