Does Claude Code keep running after you close your laptop?
A local Claude Code process cannot make progress while your laptop sleeps. Learn what terminal persistence and remote compute change.
A local Claude Code process cannot make progress while your laptop sleeps. If Claude Code runs on another computer that stays awake, closing your laptop does not suspend that remote computer. The important question is where the task executes.
This answer concerns Claude Code in a terminal. Claude's web tasks and other managed remote workflows have their own execution lifecycle. Check the official Claude Code overview to identify which surface you are using.
Why Claude Code Stops When Your Laptop Closes
Closing a lid and putting a computer to sleep are not always the same action. Power settings and external-display configurations can change the behavior. If the operating system suspends, however, local commands and network activity pause. The process may resume on wake; it does not necessarily die or lose all its files. An active network request or child command can still fail.
| Where the agent runs | What a sleeping laptop changes |
|---|
| | Local terminal | The agent and local commands stop making progress until wake. | | Local terminal inside tmux | tmux preserves the terminal session, but cannot override system suspend. | | Remote computer inside a persistent terminal | The remote process can continue while the remote host stays running. | | Provider-managed remote task | Execution follows that provider's task, timeout and billing rules. |
Locking the screen alone is different from sleeping. A locked computer can still execute work; its power policy determines whether it later suspends.
The tmux Approach and Its Limits
On an always-running remote server, tmux can keep a terminal session alive when SSH disconnects. On your laptop, it cannot make a suspended processor run. You still need to manage the remote server, agent authentication and repository access.
Keeping a laptop awake can be reasonable for a short supervised task. Moving execution to a remote computer is useful when the task needs to outlast the laptop's power or connection. Neither approach guarantees that an agent will finish: it can encounter a permission prompt, a provider limit, an error or a task it cannot solve.
Running Claude Code on a Dedicated Cloud Computer
Matrix provides a cloud computer you can access through the desktop app, browser and CLI. Run Claude Code in that computer's Terminal, rather than in a local terminal on your Mac. Your laptop then displays the remote session.
Follow the step-by-step Matrix setup and reconnect tutorial. It covers signing in, starting a bounded repository task, reconnecting and checking the output. If you already have a computer, start with the Matrix quickstart.
What Persistence Actually Requires
There are three separate things to check:
- Compute: the cloud computer must remain running under the selected plan and lifecycle settings.
- Session: the agent must run in a terminal session that can survive the client detaching.
- Progress: files, test logs and Git changes should record what happened, even if the process later exits.
A machine reboot stops processes. A provider authentication failure can interrupt an agent. Saved files do not imply that every agent's conversation can be restored or steered from every Matrix surface. Test reconnecting with your agent and use its supported resume flow when needed.
Frequently Asked Questions
Does Claude Code stop when I close my laptop?
If it runs locally and the laptop sleeps, it pauses execution. If it runs remotely, the laptop closing does not itself suspend the remote host.
Can I use tmux or screen to keep Claude Code running?
Yes, on a remote computer that remains awake. Running either locally does not defeat system sleep.
What happens to the agent's work if my internet connection drops?
A detached remote terminal can continue. Reconnect to the same session and inspect its state; a disconnect is not proof that the agent finished or that its provider connection stayed healthy. Check files and logs before starting another run.
Does this work with other AI coding agents besides Claude Code?
The same local-versus-remote distinction applies to terminal tools such as Codex CLI and Gemini CLI. Managed background agents already execute remotely and follow their provider's lifecycle.
What should I try first?
Run a small task with a visible output, reconnect once, and inspect the result before leaving a larger task unattended. Use the Matrix walkthrough for the setup.
