great-rain-98263
11/08/2025, 8:42 AMprocess did not exit in time, killing process errors after a room disconnect (reason: RoomClosed). The agent hangs instead of shutting down cleanly. Any idea how to fix or configure proper shutdown behavior?tall-airline-16756
11/08/2025, 8:42 AMtall-airline-16756
11/08/2025, 8:44 AMprocess did not exit in time, killing process after a room disconnect (reason: RoomClosed). This usually happens when the agent doesn’t shut down gracefully within the set timeout. Don’t worry, I’m here to help you through it! Here are some friendly steps you can try to resolve this:
1. Ensure proper disconnection: It’s important to always await room.disconnect() during shutdown so the room disconnects smoothly.
2. Optimize shutdown callbacks: Try to avoid any blocking I/O operations during shutdown. Instead, use non-blocking or fire-and-forget approaches for things like logging or HTTP requests.
3. Increase shutdown timeout: You might want to adjust the shutdown_process_timeout in WorkerOptions to give your agent a bit more time to clean up, for example, 120 seconds.
4. Handle session closure: If you’re working with voice agents, make sure to call session.aclose() to properly drain tasks and free resources.
5. Offload heavy cleanup: For any long-running cleanup tasks, consider delegating them to external services or using asynchronous fire-and-forget operations.
Please feel free to reach out if you’d like me to walk you through some detailed code examples or if you need any further assistance implementing these fixes. I’m here to support you every step of the way!
Sources: agents/src/ipc/job_proc_lazy_main.ts | Job lifecycle | LiveKit Docs | livekit-agents/livekit/agents/voice/agent_session.py | Agent Session & Client Integration | livekit/livekit_composite | DeepWiki