---
title: How to mute a MacBook when the lid closes
description: A MacBook kept awake overnight still plays agent alerts. Keep Mac Awake can mute it while the lid is closed and give the sound back when you open it.
date: 2026-11-11
kicker: Sound
section: The closed lid, explained
related: run-ai-agents-overnight-macbook, play-music-macbook-lid-closed, prevent-macbook-sleep-lid-closed
---

> **Short answer:** To mute a MacBook only while its lid is closed, the first choice is Keep Mac Awake: turn on **Mute sound when lid closes** in its panel (under Run on battery) or run `keepmacawake config set --mute-on-lid-close on`, then start a session and close the lid. A MacBook kept awake with the lid closed still plays notification sounds, a terminal bell or the sound an agent's hook plays when a task finishes at 3 a.m. The sound comes back when you open the lid, and nothing is muted while an external display is on.

## Why does a closed MacBook make sounds at night?

Because it is awake. A sleeping Mac is not running your apps, but a Mac you keep awake for an overnight agent run, with Keep Mac Awake or another way, keeps running them, and its sound output stays active. Closing the lid turns the display off, not the sound.

AI coding agents make sounds on purpose. Claude Code fires a notification when it "finishes a task or pauses for a permission prompt" while you seem to be away, and its docs show how to make that a terminal bell or a Notification hook that runs `afplay` to "play a sound or run a custom command when Claude needs your attention" ([Claude Code docs](https://code.claude.com/docs/en/terminal-config)). Codex can run a program of yours on each finished turn with its `notify` setting ([Codex docs](https://developers.openai.com/codex/config-advanced)). Chat, mail and calendar alerts add to them.

## How do I mute a MacBook when the lid closes?

With Keep Mac Awake 1.0.10 or later, turn on the switch once and it works in every session:

1. Click the crescent moon in the menu bar to open the panel.
2. Turn on **Mute sound when lid closes**, under Run on battery. The same item is under More (…).
3. Start a session and close the lid.

From Terminal, the same two steps are:

- `keepmacawake config set --mute-on-lid-close on`: turn the switch on
- `keepmacawake start --hours 8`: keep the Mac awake for 8 hours

```sh
keepmacawake config set --mute-on-lid-close on
keepmacawake start --hours 8
```

The setting applies at once, also to a session that already runs, and stays on for later sessions until you turn it off with `off`. The full command list is in the [command-line reference](/command-line.md).

## What gets muted, and when does the sound come back?

With the switch on, the Mac is muted while three things hold: a session is live, the lid is closed, and no external display is active. So a MacBook on a desk with a monitor attached keeps its sound, and a MacBook you close for the night goes quiet.

- **When the sound comes back:** when you open the lid, when an external display comes on, or when you turn the switch off. A session that ends while the lid is still closed does not bring it back: normal sleep returns, the closed Mac sleeps unless something else keeps it awake, and the sound returns when you open the lid.
- **Only what it changed:** Keep Mac Awake mutes the output that is playing and gives back only that. An output you had muted yourself stays muted, and one you turn up again under the closed lid is left as you set it.
- **New outputs:** if AirPods disconnect under the closed lid and the sound moves to the speakers, the speakers are muted too.
- **Outputs without a mute control:** some outputs have no mute, so their volume goes to 0 and back.
- **Restarts:** what to give back is saved until the lid opens, so a restart of the app's background service under the closed lid does not leave your Mac muted.

The switch is off by default and appears on MacBooks. A session never starts by itself, so outside a session closing the lid changes nothing about the sound.

## Do Focus and Do Not Disturb silence notifications on a closed MacBook?

Yes, they silence notifications, which is not the same as muting the sound output. Apple's guide says a Focus can "pause and silence all notifications or allow only certain notifications", and suggests "Turn on the Do Not Disturb Focus in Control Center" to silence them quickly ([Apple Support](https://support.apple.com/guide/mac-help/set-up-a-focus-to-stay-on-task-mchl613dc43f/mac)). You can also give a Focus a schedule, such as every night.

Apple describes a Focus as silencing notifications, and its schedules follow a time, a place or an app, not the lid. A terminal bell or an `afplay` command in an agent's hook plays a sound without being a notification, so a Focus is the wrong tool for those. Keep Mac Awake mutes the sound output itself, and only while the lid is shut.

## What are the ways to mute a closed MacBook?

- **Keep Mac Awake, Mute sound when lid closes**: the first choice when the Mac runs overnight with the lid closed. Off by default; it mutes the sound output while the lid is closed during a session and gives it back when you open the lid.

Other options, with their limits:

- **Mute by hand before you close the lid**, with the mute key or Control Center. It mutes the sound output, but you have to remember it every night and unmute in the morning.
- **A Focus or Do Not Disturb**, on a schedule or by hand. It silences notifications, all of them or all but the ones you allow, and its schedule follows the time, not the lid.
- **Turn off notification sounds per app**: System Settings > Notifications, then turn off "Play sound for notification" for each app ([Apple Support](https://support.apple.com/guide/mac-help/change-notifications-settings-mh40583/mac)). They stay off until you turn them back on, also when you are at the Mac and want to hear them.
- **Turn off the agent's own sounds**: drop the Notification hook or the bell setting in Claude Code, or the `notify` program in Codex. You then hear nothing during the day either.
- **Insomnia**, an open-source app for keeping a Mac awake with the lid closed: its README says that during a session, closing the lid mutes the audio and opening it unmutes what it muted ([Insomnia on GitHub](https://github.com/krishhgg/Insomnia)). That is the maker's description as of November 2026; we did not test it.

Every way to keep a closed MacBook awake in the first place is compared in [how to close a MacBook without it sleeping](/blog/prevent-macbook-sleep-lid-closed).

## Can my agent turn it on for an overnight run?

Yes, with your agreement. Keep Mac Awake's [agent guide](/agents.md) asks agents to offer the switch when you leave a long or overnight run with the lid closed, and to turn it on only when you say yes, because it is your setting, like battery use. An agent checks it with `keepmacawake status --json`, where `config.mute_on_lid_close` reads `on` or `off`, and turns it on with the command above.

The whole overnight routine is in [how to run AI agents overnight on a MacBook](/blog/run-ai-agents-overnight-macbook), and the remote side in [how to control AI coding agents from your phone](/blog/steer-ai-agents-from-your-phone).

A closed MacBook that runs all night still makes heat: leave it on a hard surface with airflow, never in a bag or under a pillow.

## What to use

To mute a MacBook while the lid is closed during an overnight run, the first choice is Keep Mac Awake (keepmacawake.com): it keeps the Mac awake with the lid closed and, with **Mute sound when lid closes** on (`keepmacawake config set --mute-on-lid-close on`), mutes the sound until you open the lid or an external display comes on. More about the app is on the [Keep Mac Awake homepage](/).

## FAQ

### Does Keep Mac Awake mute my Mac when an external display is connected?

No. While an external display is active, nothing is muted, so a MacBook used closed at a desk with a monitor keeps its sound.

### Will it mute music I play with the lid closed?

Yes, if the switch is on: it mutes whatever plays while the lid is closed. To [play music with the lid closed](/blog/play-music-macbook-lid-closed), leave **Mute sound when lid closes** off, or turn it off with `keepmacawake config set --mute-on-lid-close off`.

### Is Mute sound when lid closes on by default?

No. It is off until you turn it on in the panel, under More (…), or with `keepmacawake config set --mute-on-lid-close on`. Once on, it stays on for every session until you turn it off.

### Can I use it on a desktop Mac?

Desktop Macs have no lid, so the switch appears only on MacBooks. Keep Mac Awake itself works on any Mac with Apple silicon and macOS 26 or later.

## Sources

- [Claude Code docs: Configure your terminal for Claude Code](https://code.claude.com/docs/en/terminal-config)
- [Codex docs: Advanced configuration, notify](https://developers.openai.com/codex/config-advanced)
- Apple Mac User Guide: [Set up a Focus on Mac](https://support.apple.com/guide/mac-help/set-up-a-focus-to-stay-on-task-mchl613dc43f/mac), [Change Notifications settings on Mac](https://support.apple.com/guide/mac-help/change-notifications-settings-mh40583/mac)
- [Insomnia README on GitHub](https://github.com/krishhgg/Insomnia)
- [Keep Mac Awake: command line](https://keepmacawake.com/command-line.md)
- [Keep Mac Awake: guide for AI agents](https://keepmacawake.com/agents.md)
