Skip to content

fix(macos): app hangs on quit and must be force-killed#162

Open
henricook wants to merge 1 commit into
Sathvik-Rao:mainfrom
henricook:fix/macos-clean-shutdown
Open

fix(macos): app hangs on quit and must be force-killed#162
henricook wants to merge 1 commit into
Sathvik-Rao:mainfrom
henricook:fix/macos-clean-shutdown

Conversation

@henricook

@henricook henricook commented Jul 9, 2026

Copy link
Copy Markdown

On macOS the app never quits cleanly - the menu-bar Quit stops the tray icon, but the process stays hung and has to be force-killed (and it blocks OS shutdown/logout with the "app failed to quit" nag).

  • Cause: a pystray + tkinter teardown trap. After icon.stop() the main thread comes out of pystray's NSApplication loop and tries to finalize the interpreter, but the tkinter root is never destroyed and several native daemon threads (websocket-client blocked in an SSL recv, pasteboard/pyobjus, and the aiortc asyncio loop in P2P mode) stall finalization. Daemon flags don't help here - the stall is in the finalization itself, so the process just hangs.
  • Fix: once the websocket is disconnected and the single-instance lock released, os._exit(0) on macOS so it terminates immediately instead of waiting on the stuck clean-exit path. Both Quit and Logoff-and-Quit funnel back through run()'s finally, so this one spot covers both.
  • Scoped to macOS - Windows/Linux exit fine today and are left untouched.

@henricook henricook marked this pull request as ready for review July 9, 2026 07:39
pystray's NSApplication run loop, the tkinter interpreter that is never destroyed, and the native daemon threads (websocket-client, pasteboard, aiortc) stall interpreter finalization after the tray icon stops, so the process hangs on quit and has to be force-killed.

Force immediate termination with os._exit(0) once the websocket is disconnected and the single-instance lock has been released.
@henricook henricook force-pushed the fix/macos-clean-shutdown branch from 2d046ac to 57146dd Compare July 9, 2026 07:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant