[Unit] Description=Gracefully exit Claude Code sessions before shutdown Documentation=https://github.com/oreillyit/claude-foundations # Run before the system begins tearing down the session Before=shutdown.target halt.target reboot.target poweroff.target [Service] Type=oneshot RemainAfterExit=yes # ExecStart is a no-op — the service exists purely for its ExecStop ExecStart=/bin/true # On stop (triggered at shutdown): gracefully exit all Claude tmux sessions ExecStop=%h/dev/claude/projects/claude-foundations/scripts/claude-sessions-shutdown # Allow up to 120s for Claude sessions to save and exit cleanly TimeoutStopSec=120 [Install] WantedBy=default.target