Cleanup counts a worker gone once its socket refuses connections, and the worker stops listening before its process exits. The test checked the worker pid right after closeTerminals() resolved, so it failed whenever the worker was still exiting. Wait for the pid to disappear, as the adjacent shutdown tests do.