How to Keep a Laptop Running with the Lid Closed

Closing the lid does not have to mean going to sleep. Both Windows and macOS have a supported way to change it - useful for external monitors, overnight jobs, and running a laptop as a small always-on machine. There is also a thermal warning here worth reading before you do it.

Why lid close is a separate setting

Lid close is not part of the idle timer. It is a hardware event: a magnetic or hall-effect sensor detects the lid shutting and fires an action defined in your power configuration. This is why every keep-awake trick - jigglers, PowerToys Awake, caffeinate - fails to prevent it. They all work on idleness, and this is not idleness.

Windows

Windows exposes lid-close behaviour separately for battery and mains power.

  1. Press Windows key + R, type control powercfg.cpl and press Enter.
  2. In the left sidebar, click Choose what closing the lid does.
  3. You will see a small grid: "When I close the lid" with an On battery and a Plugged in column.
  4. Set the Plugged in column to Do nothing.
  5. Click Save changes.

Leave the battery column as Sleep. A laptop that stays awake in a bag on battery is a laptop that will be flat and hot when you open it.

The screen stays on, which you probably do not want

With "Do nothing" set, the internal display remains powered even though nobody can see it. If you are using an external monitor, tell Windows to use only that: press Windows key + P and choose Second screen only. The laptop panel powers down properly, and the machine stays awake.

If the option is missing

On some systems the lid options do not appear, usually because of a manufacturer power management utility or a policy setting. From an elevated Command Prompt you can set it directly:

powercfg /setacvalueindex SCHEME_CURRENT SUB_BUTTONS LIDACTION 0
powercfg /setactive SCHEME_CURRENT

The action values are 0 for Do nothing, 1 for Sleep, 2 for Hibernate, 3 for Shut down. Use setdcvalueindex instead for the battery case.

macOS

Apple's position is stricter: closed-lid operation is officially supported only in clamshell mode, meaning the Mac must be on power and have an external display plus an external keyboard or mouse connected. Meet those conditions and it works with no configuration at all - close the lid and the Mac keeps running on the external screen.

Without an external display, macOS will sleep on lid close and there is no supported setting to change it. Third-party utilities can override this by holding a sleep assertion, but they are working against the intended behaviour rather than configuring it, and they warrant the thermal caution below more than anything else on this page.

For everything short of lid close - display sleep, system sleep during a long job - the built-in caffeinate command is the right tool. See keeping a Mac from sleeping.

The thermal warning

This is the part people skip and then regret.

Most laptops vent through the hinge area or the underside, and many are designed on the assumption that the lid is open when the machine is under load. Running a closed laptop at full CPU - a render, a compile, a video export - can mean:

Reasonable precautions: never run a closed laptop on a bed, sofa, or anything soft; raise it on a stand or on its edge in a vertical dock so air can move; and if you are doing this regularly for heavy work, open the lid and use Second screen only instead - you get the same result with the cooling the machine was designed around.

Practical setups

Docked at a desk

Windows: lid action "Do nothing" on mains, Windows+P set to Second screen only. macOS: connect power, external display and a peripheral, then close the lid - clamshell mode handles it.

Overnight download or backup

Keep the lid open if you can, and just prevent sleep - PowerToys Awake without "keep screen on", or caffeinate -i. The screen turns off, the work continues, and the machine breathes. This is nearly always better than closing the lid.

Laptop as a small server

Lid closed, on mains, propped vertically in a stand, on a hard surface with clear airflow. On Windows also disable hibernate (powercfg /hibernate off) and set the sleep timeout to Never for the plugged-in state.

What this does not solve

Keeping the machine running with the lid closed does not stop it locking, and does not keep a chat status active - the idle timer is still running, because nobody is providing input. If that is your actual problem, you need input rather than an awake system: see the full list of options, or use a browser-based jiggler with an external mouse, which pairs naturally with a docked setup since you have one connected anyway.