Mac won't sleep after Claude Code
If the work is done but your Mac won't sleep, or the battery dropped overnight, first find out what's holding it awake.
Lidnight stops runaway spend, silent approval stalls, and unexpected limit hits while you step away. Track Claude Code, Codex, Antigravity, Gemini and Kiro sessions, limits and cost, approve from your phone, and keep going with the lid closed.
Lidnight is a Mac app, so it can't be installed on this device. Open this address on your Mac to download it.
Copied. Paste it on your Mac to open it.
Couldn't copy. Tap the address below to select it, then copy.
Find what's holding it awake
Run pmset -g assertions in Terminal to see which processes are blocking sleep. If caffeinate shows up next to PreventUserIdleSystemSleep, something started it; pgrep -fl caffeinate shows the exact command.
While a session is active, Claude Code repeatedly starts caffeinate -i -t 300 to block idle sleep. It respawns every five minutes, so killall caffeinate doesn't stick, and there's no setting to turn it off yet (issue #21432).
Fixing it yourself
The surest fix is to close finished sessions (/exit, or close the terminal window). If you ever ran sudo pmset -a disablesleep 1, check whether SleepDisabled is 1 in pmset -g and undo it with sudo pmset -a disablesleep 0; it survives restarts.
To sleep as soon as work ends with the lid closed, a Stop hook can check the lid and call pmset sleepnow (no sudo). The catch: with several sessions open, it sleeps when any one of them finishes.
With Lidnight
Lidnight watches every Claude Code and Codex session's hooks and sleeps the Mac 10 minutes after the last one goes quiet. With the lid closed it doesn't stay up once the work is done, and while work runs it keeps going lid-closed. It also sleeps at your battery floor or at 45°C. Ways to keep a Mac awake compared
Try Lidnight free
Apple Silicon Macs · macOS 13 or later. Every download includes a free trial of everything in Pro (14 days or 5 lid-closed runs of 10+ minutes, whichever comes first), no payment details needed. Pro is a one-time payment (1 Mac $9.99 · 3 Macs $14.99 USD, plus regional tax) with a 14-day full refund, no questions asked.
Lidnight is a Mac app, so it can't be installed on this device. Open this address on your Mac to download it.
Copied. Paste it on your Mac to open it.
Couldn't copy. Tap the address below to select it, then copy.