First, read why it shut down
Your Mac writes down a reason every time it powers off. Reading it points you straight at the cause instead of guessing. Open Terminal (press ⌘ Space, type Terminal, Return) and run:
% pmset -g log | grep -i "shutdown cause"Shows the recorded reason for each recent shutdown. Look at the most recent line.
The number is the clue. A positive value like 5 or 3 is a normal or forced shutdown — you held the power button, or the software asked for it. A negative value is an unexpected one the Mac didn't choose: -3 specifically means it overheated, and other negatives point to a power or system fault. That tells you which section below to read.
It's overheating
The Mac was hot and the fans were roaring right before it died; it often happens under heavy load or in a warm room. Shutdown cause -3.
When a Mac can't shed heat fast enough, it powers off to protect the chips inside — a hard safety cutoff. The trigger is trapped heat: blocked vents, a soft surface like a bed or couch, caked-in dust, or one program working the processor flat out.
Fixmove the Mac onto a hard, flat surface with clear vents, get it out of direct sun, and quit whatever was working hardest (open Activity Monitor, sort by % CPU, quit the top item). If it keeps overheating, the deeper fixes are in the overheating guide.
NoahNoah checks the thermal and shutdown logs together, names the process that was cooking the machine, and — with your OK — quits it and clears what was driving the heat up, so the next shutdown doesn't happen.
It's a power or battery problem
It cuts out instantly with no heat and no warning, sometimes only when unplugged, or only at a certain battery level.
An instant power loss usually means the electricity stopped, not the software. On a laptop that's a worn-out battery (one that can't hold the charge it reports), a failing charger, or a bad cable. On a desktop it's the power cord or outlet.
Check the battery's health: open > System Settings > Battery, click the ⓘ next to Battery Health. “Normal” is good; “Service Recommended” means the battery is worn.
Fixon a laptop, try a different charger and outlet — a borrowed known-good charger settles it fast. If Battery Health says Service Recommended and it dies away from the wall, the battery needs replacing. On a desktop, reseat the power cable at both ends.
A crash restarted it (kernel panic)
It restarts rather than staying off, and you see “your computer restarted because of a problem.”
That message is a kernel panic — a crash in the core of macOS itself, serious enough that the safest move is a restart. It's usually caused by a buggy driver, a failing accessory, or an app that reaches deep into the system (antivirus tools and virtual machines are common triggers). If it happens once and never again, ignore it. If it repeats, hunt the cause.
Fixinstall any pending update from > System Settings > General > Software Update, update or remove third-party drivers and security tools, then unplug every accessory and add them back one at a time until the panic returns — the last one you added is the culprit.
NoahNoah reads the panic report you never think to open, points to the driver or app named in it, and tells you what to update or remove — instead of leaving you with a scary message and no next step.
If it's still happening
If it's not heat, not power, and not a panic, a reset of the Mac's low-level power controller can clear a stuck state. On Apple-silicon Macs (M1 and later) there's nothing to reset by hand — just shut down fully and leave it off for 30 seconds, which does the same thing. On older Intel Macs, look up the SMC reset for your model.