ILifecycleApi.onStopping(fn: () => void | Promise<void>): void
Runs at the very start of stop(), before the application begins
refusing new requests.
This is the only hook that runs while the application is still serving
normally, which is what makes it the right home for "tell the outside
world to stop sending me traffic" work — deregistering from a service
registry, for instance. Deregistering in onShutdown instead
means the socket is already closed by the time the registry hears about
it, so callers keep being routed to a dead port for up to one health-check
interval on every rolling deploy.
Hooks run LIFO and are awaited, so a slow hook delays the whole shutdown
and a rejecting one surfaces from stop() — but only after the shutdown
has completed, because a hook failure must not be able to prevent the
application stopping. With no hooks registered this
window has zero width and stop() behaves exactly as it did before.