matrix.log / guides / does-claude-code-keep-running-after-laptop-closes
GuidesClaude Code
All articles

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.

Matrix OSPublished Updated 4 min read

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 runsWhat 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:

  1. Compute: the cloud computer must remain running under the selected plan and lifecycle settings.
  2. Session: the agent must run in a terminal session that can survive the client detaching.
  3. 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.

Try a first task in Matrix

Check where Claude executes, then try a small remote task and reconnect to it.

Matrix desktop app showing Terminal, Files, Editor and Chat launchers
Start from the Matrix desktop app. Open Terminal for a coding task, or Chat to prepare a draft; inspect saved output in Files or Editor.
  1. Follow the quickstart to sign in, choose a computer and complete any required provisioning. To use the native app, follow the desktop installation and approval steps.
  2. Open a separate session with a small sample project or synthetic input. Configure the agent access needed for that task and make the expected output explicit.
  3. Look for progress in the same session and saved files, not just an open terminal tab.

For a worked coding example, use the setup and reconnect walkthrough. Inspect the result before expanding the scope or leaving a longer task unattended.

Open Matrix →Read the quickstart →Current plans and pricing →