Even if you have the "Prevent automatic sleeping on power adapter when the display is off" setting turned on, macOS can sometimes override this behavior due to overlapping configuration rules, a corrupted power plist file, or the laptop being physically closed.
Are you closing the MacBook lid? (Clamshell Mode)
If you are closing the laptop lid while your task runs, the M1 MacBook will always force itself to sleep to save power and prevent overheating. The only exception is if it is fully in "Clamshell Mode," which requires three things simultaneously:
- The power adapter is plugged in.
- An external monitor is connected and active.
- An external keyboard and mouse/trackpad are connected.
If you close the lid without an external monitor attached, it ignores your "prevent sleep" settings entirely and goes to sleep. To leave it running with the screen off, you must leave the lid open and let the display turn off via its normal inactivity timeout.
Force the background task to stay awake using caffeinate
If your background script or application doesn’t explicitly declare a "Power Assertion" (a signal to macOS saying "I am doing heavy lifting, don't sleep"), the OS might mistakenly flag the system as idle.
The most foolproof way to handle this for non-interactive tasks is via the Terminal:
- Open the Terminal app.
- Type caffeinate and hit return.
As long as that Terminal window is open, your Mac will not sleep. When your task is finished, go back to the Terminal and press Control + C to allow the Mac to sleep normally again.
Clear corrupted power management files
If the lid is open and it’s still sleeping, your power configuration cache file may have become corrupted during your upgrade. You can force macOS to rebuild it:
- Open Terminal.
- Run the following command (it will ask for your Mac's login password, nothing will show on the screen as you type it):
sudo rm /Library/Preferences/SystemConfiguration/com.apple.PowerManagement.plist
- Restart your Mac.
- Go back to System Settings > Battery > Options and toggle the "Prevent automatic sleeping..." option off and back on to rewrite a clean file.
Double-check the Lock Screen timing
Sometimes a mismatch between your display sleep and lock screen security forces a hard sleep. Go to System Settings > Lock Screen. Ensure that "Turn display off on power adapter when inactive" is set to a reasonable time (e.g., 10 or 15 minutes) rather than "Never," as letting the display turn off natively is what triggers your core "Prevent automatic sleeping" rules to correctly keep the background CPU alive.
One more point – is your Mac going to sleep, or are you being logged out? If the latter, there is a 'hidden' setting that causes that (not hidden per se, just somewhere most people don't think to look).
Go to System Settings > Privacy & Security > Advanced (button at the bottom) and toggle OFF the setting to Log out automatically after inactivity.

More information from Apple: Set your Mac to log out when not in use - Apple Support