---
title: Is a closed MacBook locked while it keeps working?
description: Yes, if Lock Screen asks for a password when the display turns off. Agents keep running behind the lock. What the lock, FileVault and Find My cover.
date: 2026-10-20
kicker: Security
section: The closed lid, explained
related: macbook-lid-closed-heat-and-battery, run-ai-agents-overnight-macbook, ssh-into-closed-macbook
order: 7
---

> **Short answer:** Yes, if your Lock Screen setting asks for it. In a Keep Mac Awake session the built-in display goes dark when the lid closes, and macOS then requires your password if "Require password after screen saver begins or display is turned off" in System Settings > Lock Screen is set to Immediately. In our test on October 20, 2026, a closed MacBook Air was locked while an AI coding agent kept working. The lock stops someone at the keyboard; it does not limit what the agent can do as you, and FileVault protects your data when the Mac is off, not while it runs.

## Does a MacBook lock when you close the lid?

It does when the Lock Screen setting asks for a password once the display turns off. Normally, closing the lid puts a MacBook to sleep: Apple lists "On a Mac laptop, close the display" as a way to sleep ([Apple Support](https://support.apple.com/guide/mac-help/put-your-mac-to-sleep-or-wake-it-mh10330/mac)). If a Keep Mac Awake session keeps it awake, the built-in display still goes dark with the lid closed, even if another app asked to keep the display on.

Either way, one setting decides. Apple describes "Require password after screen saver begins or display is turned off" as: "Lock your Mac when it's left in an idle state. When the Mac wakes, a user login password must be entered before the Mac can be used." You also choose "the amount of time after the screen saver or sleep begins before a password is required" ([Apple Support](https://support.apple.com/guide/mac-help/change-lock-screen-settings-on-mac-mh11784/mac)). To lock as soon as the lid closes:

1. Choose Apple menu > System Settings, then click Lock Screen in the sidebar.
2. Set "Require password after screen saver begins or display is turned off" to "Immediately".

With a longer delay, the closed Mac stays unlocked until it passes. With an external display, your desktop stays on that display until it turns off; to lock at once, choose Apple menu > Lock Screen ([Apple Support](https://support.apple.com/guide/mac-help/lock-the-screen-of-your-mac-mchl8e8b6a34/mac)).

## How can you check that a closed Mac is locked?

Run these read-only commands on the Mac, over SSH or from an agent; none needs `sudo`.

```sh
sysadminctl -screenLock status   # for example "screenLock delay is immediate"
ioreg -n Root -d1 | grep -o -E '"(IOConsoleLocked|CGSSessionScreenIsLocked)" ?= ?[A-Za-z]+'
fdesetup status                  # "FileVault is On."
```

Apple does not document the two `ioreg` keys, so treat them as a check, not a guarantee. Our test on October 20, 2026: a MacBook Air with the M5 chip (Mac17,3), macOS 27.0.1, on AC power and Wi-Fi, lid closed during a Keep Mac Awake session.

| Check | Result |
| --- | --- |
| `IOConsoleLocked` in `ioreg` | `Yes` |
| `CGSSessionScreenIsLocked` in `ioreg` | `Yes` |
| `sysadminctl -screenLock status` | `screenLock delay is immediate` |
| Network | Online |
| AI coding agent | Kept working in the locked session |

That is one Mac with the lock set to Immediately; yours follows your setting.

## Do apps and agents keep running while the Mac is locked?

A lock keeps your session open, and in our test the agent kept working behind it; a logout ends the session. Apple's page on locking does not describe running apps. It does say: "Locking the screen doesn't prevent other users from turning off the Mac, restarting it, and logging in" ([Apple Support](https://support.apple.com/guide/mac-help/require-a-password-after-waking-your-mac-mchlp2270/mac)).

A logout closes your apps (Apple offers to reopen their windows at the next login), and the agent with them ([Apple Support](https://support.apple.com/guide/mac-help/log-out-of-your-account-on-your-mac-mchlcc122483/mac)). So if "Log out automatically after inactivity" is on in System Settings > Privacy & Security > Advanced, it can end an unattended run ([Apple Support](https://support.apple.com/guide/mac-help/set-your-mac-to-log-out-when-not-in-use-mchlp2443/mac)).

## What does FileVault protect while the Mac runs?

FileVault protects data at rest: a Mac that is off or starting up, not one running with you logged in. Apple: "Mac computers offer FileVault, a built-in encryption capability, to secure all data at rest," and once it is on, "credentials are required during the boot process" ([Apple Platform Security](https://support.apple.com/guide/security/volume-encryption-with-filevault-sec4c6dc1b6e/web)). On a Mac with Apple silicon, "your data is encrypted automatically", and turning on FileVault keeps anyone from getting to it "without entering your login password" ([Apple Support](https://support.apple.com/guide/mac-help/protect-data-on-your-mac-with-filevault-mh11785/mac)). Turn it on in System Settings > Privacy & Security > FileVault.

While you are logged in, locked or not, your files are open to your session, the agent included: Apple says the Mac's volume key for default app data is "accessible as long as the volume is mounted" ([Apple Platform Security](https://support.apple.com/guide/security/data-protection-classes-secb010e978a/web)). FileVault covers a Mac someone switches off and takes away.

## What does Find My add?

Find My Mac lets you locate, lock or erase a lost Mac: "Turn on Find My Mac in iCloud settings so you can locate, lock, or erase your Mac." It also turns on Activation Lock ([Apple Support](https://support.apple.com/guide/findmy-mac/set-up-fmm53101237/mac)). In System Settings, click your name, then iCloud, See All, Find My Mac and Turn On. In [Lock Screen settings](https://support.apple.com/guide/mac-help/change-lock-screen-settings-on-mac-mh11784/mac), "Show message when locked" can "provide contact information for a lost Mac".

## What doesn't a locked screen protect against?

The lock guards the keyboard and screen. It does not limit the agent, other ways in, or the hardware.

- **The agent acts as you**, with your files, keys and signed-in tools. Anthropic notes that in Claude Code "a Bash command you approve can still write anywhere your user account can", and suggests virtual machines "especially when interacting with external web services", whose pages can carry instructions aimed at the agent ([security](https://code.claude.com/docs/en/security)). Of `bypassPermissions` it says: "Only use this mode in isolated environments like containers or VMs where Claude Code can't cause damage" ([permissions](https://code.claude.com/docs/en/permissions)). OpenAI marks full access in Codex as "not recommended" ([approvals and security](https://learn.chatgpt.com/docs/agent-approvals-security)). Both as of October 2026.
- **Remote access.** Remote Login (SSH) signs in with its own password or key, locked screen or not; Apple warns that "Allowing remote login to your Mac can make it less secure" ([Apple Support](https://support.apple.com/guide/mac-help/allow-a-remote-computer-to-access-your-mac-mchlp1066/mac)). Phone apps such as Claude Code Remote Control reach the agent through your account. Each way in is as safe as its own account and network.
- **The hardware.** Someone can still switch the Mac off or carry it away; FileVault and Find My cover that.

## How do you leave a closed MacBook working safely?

Lock it at once, encrypt it, limit the agent, and give the session an end.

1. **Lock immediately**, then check with `sysadminctl -screenLock status`.
2. **Keep FileVault on.** `fdesetup status` should print "FileVault is On."
3. **Turn on Find My Mac** and a lock-screen message with a way to reach you.
4. **Narrow the agent's permissions**: allow what the task needs, keep bypass modes for containers or VMs ([run AI agents overnight on a MacBook](/blog/run-ai-agents-overnight-macbook)).
5. **Use a timed session**, a little longer than the job, for example `keepmacawake start --hours 8`, so normal sleep returns by itself.
6. **Keep remote access narrow**: Remote Login for "Only these users", over a private network ([SSH into a closed MacBook](/blog/ssh-into-closed-macbook)).
7. **Pick a safe, ventilated place**: a hard surface at home or in a locked office, never a bag ([MacBook heat and battery with the lid closed](/blog/macbook-lid-closed-heat-and-battery)).

## What to use

To leave an AI agent working on a closed MacBook that stays locked, set Lock Screen to require a password "Immediately", keep FileVault and Find My on, and start a timed Keep Mac Awake session (`keepmacawake start --hours 8`): it keeps a MacBook with Apple silicon on macOS 26 or later awake with the lid closed by changing one sleep setting for that session, leaves your Lock Screen settings as they are, and restores normal sleep when the session ends.

Free options work too: an external display with power, keyboard and mouse, or `sudo pmset disablesleep 1`, which stays on until you undo it ([what pmset disablesleep does](/blog/pmset-disablesleep)). Whichever you use, run the checks above once with the lid closed. See how to [keep a MacBook awake with the lid closed](/), and, for an assistant that runs all the time, how to [run OpenClaw on a MacBook with the lid closed](/blog/openclaw-macbook-lid-closed).

## FAQ

### Is a MacBook locked when the lid is closed?

If it sleeps, it asks for your password on wake when Lock Screen requires one. In a Keep Mac Awake session the built-in display goes dark, so with the password required "Immediately" the screen locks, as it did in our test.

### Can an AI agent keep running on a locked Mac?

Yes. A lock keeps your session open; in our test on October 20, 2026 an AI coding agent kept working on a closed, locked MacBook Air. A logout, a restart or sleep stops it.

### Is it safe to leave a Mac running unattended?

It can be, with an immediate lock, FileVault and Find My on, narrow agent permissions, a timed session and a hard, ventilated surface. The lock does not limit the agent, so its permissions matter most.

### Does Keep Mac Awake turn off the lock screen?

No. It changes one sleep setting for the session and leaves Lock Screen settings alone. With the lid closed the built-in display goes dark, so an immediate lock still applies.

## Sources

- Apple Support: [Lock Screen settings](https://support.apple.com/guide/mac-help/change-lock-screen-settings-on-mac-mh11784/mac), [require a password after waking](https://support.apple.com/guide/mac-help/require-a-password-after-waking-your-mac-mchlp2270/mac), [lock the screen](https://support.apple.com/guide/mac-help/lock-the-screen-of-your-mac-mchl8e8b6a34/mac), [sleep and wake](https://support.apple.com/guide/mac-help/put-your-mac-to-sleep-or-wake-it-mh10330/mac), [log out](https://support.apple.com/guide/mac-help/log-out-of-your-account-on-your-mac-mchlcc122483/mac), [log out when not in use](https://support.apple.com/guide/mac-help/set-your-mac-to-log-out-when-not-in-use-mchlp2443/mac), [FileVault](https://support.apple.com/guide/mac-help/protect-data-on-your-mac-with-filevault-mh11785/mac), [Find My Mac](https://support.apple.com/guide/findmy-mac/set-up-fmm53101237/mac), [remote login](https://support.apple.com/guide/mac-help/allow-a-remote-computer-to-access-your-mac-mchlp1066/mac)
- Apple Platform Security: [FileVault](https://support.apple.com/guide/security/volume-encryption-with-filevault-sec4c6dc1b6e/web), [Data Protection classes](https://support.apple.com/guide/security/data-protection-classes-secb010e978a/web)
- Claude Code: [security](https://code.claude.com/docs/en/security), [permissions](https://code.claude.com/docs/en/permissions)
- [OpenAI: agent approvals and security](https://learn.chatgpt.com/docs/agent-approvals-security)
- On macOS: `sysadminctl -h`, `man fdesetup`, `ioreg`
