Use This App to Change What Happens When You Close Your MacBook
When there's no external display connected to your MacBook, closing it puts the entire laptop to sleep. That's straightforward enough. When there is an external display, mouse, and keyboard connected, closing your MacBook allows you use it in "Clamshell" mode—that is, you can use the computer using the external display and controls.
This default behavior should cover most use cases, which is probably why Apple doesn't allow much configuration. But maybe you want the MacBook to go to sleep when you close it, even if there's a display connected. Or maybe you want the computer to shut down entirely? If that's you, check out Clamshell, a free app that lets you choose.
The application lives in the menu bar and gives you five options. There's the default behavior, which we outlined above, and then four more. Sleep will put your MacBook to sleep as soon as you close the lid, even if there's another display connected. This is great if you use an external display but never use your MacBook in clamshell mode. Beautiful.
Shut Down goes a step further by shutting your computer down entirely (this requires installing a system-wide background helper). Shutting down your computer is great if you want to preserve battery life, but is in other ways extreme—you might lose any unsaved work, and you'll need to start the laptop up again. Still, if you're using your MacBook in a public place, this is the most secure option—it's really hard to access a Mac without the password if it's completely shut down.
Those two features are easy enough to understand, but there are two more that are a touch more tricky. The first of these, Keep External Displays On & Prevent Idle Sleep, will keep the display on and also keep your displays from going to sleep. It's great if there's something on your display that you want to ensure stays visible, even if you're not actively using the laptop.
The next option, Turn Off Displays & Prevent Idle Sleep, will turn off your displays but not your device. This is great if you want your MacBook to keep playing music or downloading files while the screen is turned off. Note that this won't happen if you're not connected to power, meaning you don't have to worry about this option draining your battery.
All of these are great options to have around, which is why I'm surprised Apple doesn't offer some way to configure them in settings. The good news is that Clamshell is free and does the job well.
In some situations, you might prefer your MacBook to go to sleep when closed, even with an external display connected. This can be achieved using the 'Sleep' feature in the Clamshell app. (first sentence) Additionally, the 'Tech' world continues to provide solutions to customize your MacBook's behavior, like the 'Clamshell' app, which offers various options to manage power settings according to your needs. (second sentence)