Skip to content

Stop services when AppKit terminates the app on macOS - #21

Merged
andrewchen5678 merged 2 commits into
mainfrom
stop-services-on-macos-terminate
Sep 25, 2026
Merged

andrewchen5678 merged 2 commits into
mainfrom
stop-services-on-macos-terminate

Conversation

@andrewchen5678

Copy link
Copy Markdown
Contributor

Quitting on macOS through AppKit — the app menu's Quit (and its Cmd-Q), the Dock's Quit, or logging out — left every managed service running.

These paths call NSApplication terminate:, which exits the process from inside the event loop, so Desktop::run never reached its shutdown. The manager is now also stopped from an NSApplicationWillTerminateNotification observer (a no-op on other platforms).

Verified on macOS by sending terminate to a running instance with a sleep service: before, the app exited with no shutdown logged and sleep was orphaned under PID 1; after, the service is stopped with SIGTERM and nothing is left behind. ci/unix/ci.sh passes on Linux (including the e2e) and on macOS.

Also bumps the version to 0.0.18.

🤖 Generated with Claude Code

Andrew Chen and others added 2 commits September 24, 2026 18:21
The app menu's Quit (and its Cmd-Q), the Dock's Quit, and logging out go
through NSApplication terminate:, which exits the process from inside the
event loop, so Desktop::run never reached its shutdown and managed services
were left running. Stop the manager from an
NSApplicationWillTerminateNotification observer as well.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@andrewchen5678
andrewchen5678 merged commit 5e7442a into main Sep 25, 2026
3 checks passed
@andrewchen5678
andrewchen5678 deleted the stop-services-on-macos-terminate branch September 25, 2026 01:30
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