The following diagrams show the sequence a service worker goes through during a replacement cycle. The first diagram shows how a new service worker is registered and lives next to an existing service worker. The new service worker is not active, but hangs around, waiting for all active clients to close:

Once the clients are closed, the initial service worker dies and the new service worker begins its new active role:

After the new service worker becomes active, it is the only service worker that's alive:
