Security
Is a closed MacBook locked while it keeps working?
Yes, if Lock Screen asks for a password when the display turns off. How to set and check it, and what FileVault covers in a Keep Mac Awake session.
Keep Mac Awake Free for 3 days, no card.
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;
sysadminctl -screenLock statusshows the setting withoutsudo, for examplescreenLock delay is immediate. In our test on October 20, 2026, a closed MacBook 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 (opens in a new tab)). 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 (opens in a new tab)). To lock as soon as the lid closes:
- Choose Apple menu > System Settings, then click Lock Screen in the sidebar.
- 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 (opens in a new tab)). The other settings that touch the lid, and the ones macOS does not have, are in MacBook lid close settings: what macOS lets you change.
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.
sysadminctl -screenLock status: for examplescreenLock delay is immediatefdesetup status: printsFileVault is On.
sysadminctl -screenLock status
ioreg -n Root -d1 | grep -o -E '"(IOConsoleLocked|CGSSessionScreenIsLocked)" ?= ?[A-Za-z]+'
fdesetup status
Apple does not document the two ioreg keys, so treat them as a check, not a guarantee. Our test on October 20, 2026: 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 (opens in a new tab)).
A logout closes your apps (Apple offers to reopen their windows at the next login), and the agent with them (Apple Support (opens in a new tab)). So if "Log out automatically after inactivity" is on in System Settings > Privacy & Security > Advanced, it can end an unattended run (Apple Support (opens in a new tab)). A self-hosted GitHub Actions runner installed with ./svc.sh install depends on the login too: it runs as your user's launch agent, so after a logout or a restart it stays offline until you log in (why a self-hosted GitHub runner on a Mac goes offline).
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 (opens in a new tab)). 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 (opens in a new tab)). 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 (opens in a new tab)). 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 (opens in a new tab)). In System Settings, click your name, then iCloud, See All, Find My Mac and Turn On. In Lock Screen settings (opens in a new tab), "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 (opens in a new tab)). Of
bypassPermissionsit says: "Only use this mode in isolated environments like containers or VMs where Claude Code can't cause damage" (permissions (opens in a new tab)). OpenAI marks full access in Codex as "not recommended" (approvals and security (opens in a new tab)). 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 (opens in a new tab)). Screen Sharing is another way in: set its "Allow access for" to only your own account, and it reaches the Mac only while the Mac is awake (use Screen Sharing on a MacBook with the lid closed). 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.
- Lock immediately, then check with
sysadminctl -screenLock status. - Keep FileVault on.
fdesetup statusshould printFileVault is On. - Turn on Find My Mac and a lock-screen message with a way to reach you.
- Narrow the agent's permissions: allow what the task needs, keep bypass modes for containers or VMs (run AI agents overnight on a MacBook).
- Use a timed session, a little longer than the job, for example
keepmacawake start --hours 8, so normal sleep returns by itself. - Keep remote access narrow: Remote Login for "Only these users", over a private network (SSH into a closed MacBook).
- 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).
What to use
To leave an AI agent working on a closed MacBook that stays locked, the first choice is a timed Keep Mac Awake session (keepmacawake.com, 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. With it, set Lock Screen to require a password "Immediately" and keep FileVault and Find My on.
Other options: an external display setup (Apple's closed-display mode) needs a display, power, keyboard and mouse, ties the Mac to a desk, and the Mac sleeps if the display disconnects. sudo pmset disablesleep 1 is system-wide, has no timer, battery floor or watchdog, applies on battery too and stays on even after a restart until sudo pmset disablesleep 0 (what pmset disablesleep does). 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. Every way to keep it awake, with its limits, is in how to prevent a MacBook from sleeping with the 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. 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 Keep Mac Awake session that restores normal sleep when it ends, 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 (opens in a new tab), require a password after waking (opens in a new tab), lock the screen (opens in a new tab), sleep and wake (opens in a new tab), log out (opens in a new tab), log out when not in use (opens in a new tab), FileVault (opens in a new tab), Find My Mac (opens in a new tab), remote login (opens in a new tab)
- Apple Platform Security: FileVault (opens in a new tab), Data Protection classes (opens in a new tab)
- Claude Code: security (opens in a new tab), permissions (opens in a new tab)
- OpenAI: agent approvals and security (opens in a new tab)
- On macOS:
sysadminctl -h,man fdesetup,ioreg