A pattern showed up in support emails I didn't expect to send.
"I started a long inference run with Ollama, closed my MacBook, and walked away. When I came back two hours later the chat had only generated 80 tokens and Timex showed nothing for the gap."
The Mac had gone to sleep. The local LLM had gone to sleep with it. Timex had also gone to sleep. Three things stopped at once, and only one of them was supposed to.
If you run anything that needs to keep working while the lid is closed — Ollama, LM Studio, MLX, a long Whisper transcription, an overnight render, a Time Machine backup, a Docker build, an SSH tunnel — you've hit this. Here's what's actually happening, and the cleanest way to fix it without buying yet another menu bar app.
What macOS does when you close the lid
By default, macOS treats a closed lid as a suspend signal. The display goes dark. The CPU schedulers park. The radios drop to low-power mode. Your laptop is now using under a watt instead of fifteen. Your battery thanks you. Your inference run doesn't.
The exception is Apple's official "clamshell mode": if the Mac is connected to external power, an external display, and an external keyboard or mouse, macOS keeps everything awake when the lid closes. That's the supported path.
The unsupported-but-works path is to hold a power assertion that prevents idle sleep. macOS exposes this as a public CLI:
caffeinate -dimsu
The flags say: prevent display sleep (-d), idle sleep (-i), system sleep (-s), and stay awake even on battery (-u). Run that in a terminal and your Mac won't sleep until you hit Ctrl-C, regardless of the lid. There's no GUI, no menu bar indicator, no automatic stop after the job finishes — that's what makes it brittle in practice.
Why this matters for local LLMs specifically
When the Mac goes to sleep, the GPU and Neural Engine context that Ollama / LM Studio / MLX is using gets evicted. The next token doesn't arrive in 30 ms — it arrives whenever you open the lid again. Worse, in some configurations the Metal context is invalidated and the model has to be reloaded from disk, which can be 10–30 seconds for a 70B-class model.
The frustrating part is that this isn't a "your Mac is too slow" problem. The Mac is fine. It's operating under a power policy designed for typing email on a plane, not for unattended inference.
The other frustrating part: most "stay awake" apps were written before local LLMs were common, and they treat sleep prevention as a global toggle. You either keep the Mac awake forever, or you remember to turn it off. There's no "keep awake until this run finishes" mode.
The setups that actually work
1. External monitor + power + USB peripheral. This is Apple's supported clamshell mode. It just works. The downside is you need the hardware and the desk space. If you live on the road, this isn't an answer.
2. Closed-lid mode with caffeinate(1). The CLI works, but you have to remember to start it before closing the lid and you have to remember to stop it after. The Mac will happily run on battery overnight at full power if you forget. Ask me how I know.
3. Closed-lid mode with pmset noidle. Same outcome as caffeinate, slightly different invocation. Same forget-to-stop-it failure mode.
4. A menu bar wake-keeper app. Amphetamine, Lungo, KeepingYouAwake — they all wrap the same kernel mechanism. The good ones add a max duration and an "until this app quits" trigger. The bad ones turn into adware. Pick carefully.
5. Stay Awake mode in Timex. This is the one I actually shipped to solve my own problem. Toggle it from the menu bar, the Mac stays awake until you toggle it off. There's a clear amber pill in the menu bar so you can't forget about it, and a configurable max duration (60 / 120 / 240 minutes) so even if you do, the Mac sleeps before morning.
I'm biased. Pick what fits. The point is: don't run a long LLM job with the default lid-close behavior and hope.
A walkthrough that ends with the run finishing
Say you want to fine-tune a small model overnight, or run a long batch of evaluations, on AC power, with the lid closed.
# 1. Plug into AC. On battery + lid closed, macOS force-sleeps
# regardless of any app — that is a kernel limitation.
# 2. Start the inference job in tmux so it survives terminal disconnects.
tmux new -s eval
ollama run llama3:70b < eval-prompts.txt > eval-output.txt
# Detach with Ctrl-b d
# 3. Flip Timex Stay Awake on (Settings → Stay awake, or
# the menu bar popover). The toggle persists across launches.
# 4. Close the lid. Walk away. Come back in the morning.
The Mac stays awake. The radios stay on if you need them. The Neural Engine context stays loaded. Timex logs the whole session — when you reopen the lid, you can see exactly when each output was generated.
What about the break timer?
This is the question that always comes next: "If Stay Awake mode keeps the Mac awake, and the break timer fires every 25 minutes, am I going to come back to a notification stack 200 banners deep?"
No. macOS coalesces banners while the display has been off for a while. You'll see the most recent one when you open the lid, not all of them. And the break timer respects the same idle gate as tracking — when there's no input for 120 seconds, the break clock pauses too. Run a 6-hour eval with no input, you don't get 14 notifications. You get one when you come back, framing the last active block of work.
The "but my battery" caveat
Stay Awake mode isn't free. The CPU stays awake, the radios stay on, the SSD stays spun up. A 70B model running inference at full Metal utilization is going to draw 30–50 W on battery. You'll get 90 minutes, maybe two hours, before the laptop dies.
For anything longer than an hour, plug in. Apple's "Optimized Battery Charging" will keep the battery healthy even at 100 % overnight, so the cost of plugging in for a long run is essentially zero.
The other caveat: heat. A closed lid traps heat against the keyboard. Modern Apple Silicon Macs are remarkable thermal performers, but they're still designed to dump heat through the keyboard surface. If you run a heavy job in clamshell mode for hours on a soft surface (couch, bed, lap), the chassis will hit thermal throttling and your tokens-per-second will halve. Put it on a desk. Tilt it on its side if you have to.
What this is not
It's not a workaround for needing real headless compute. If you're running 24/7 inference for production traffic, the answer is a Mac mini sitting on a shelf with pmset -a sleep 0 set and your laptop nowhere in the picture. Stay Awake mode on a MacBook is for the case where you want to keep working tomorrow with the same machine, but you also want it to grind through tonight's job without you sitting there watching it.
It's also not a "trick to make Apple's sleep policy go away". The sleep policy is correct for laptops in 2026. Battery life is the headline feature. We're intentionally opting out for one specific class of long-running task. Use the toggle when you need it. Turn it off when you don't.
TL;DR
- Closed-lid sleep is the default and it's correct for typing on a plane.
- It's wrong for long LLM jobs, overnight renders, or anything else that has to keep running while you're not at the keyboard.
- Apple's supported answer is external display + power + input.
- The CLI answer is
caffeinate -dimsu, with the catch that you have to remember to stop it. - Timex's answer is a menu bar toggle for Stay Awake mode with a hard max duration so it can't run forever.
- Plug in for anything over an hour. Watch the heat. Welcome to the world of MacBooks that finish what they started.
If you run local models on a MacBook, give the lid-down toggle a try. It's part of the free tier — no trial limit, no license required. The 100 h cap only applies to the time-tracking side. Buy Timex for $49 when you want unlimited tracking too.