This guide is for this exact problem:
You run: sudo shutdown -h now
Mac shuts down
Then Mac automatically powers on / reboots again
Your real case data shows:
MacBook Pro Apple M4 Pro
Internal display not visible
External monitor used as primary display
macOS detects internal display as Online
No scheduled reboot
No new May 15 panic file
Old Jan 27 panic was GPU/display firmware related: AGXk / GFX FW
Shutdown still reboots even after removing HDMI
Code language: JavaScript (javascript)
So your current strongest conclusion is:
Not VS Code
Not normal pmset schedule
Not normal app restart
Most likely hardware / firmware / display-power path issue
Your old panic strongly points to Apple GPU/display firmware: AGXk ... Failed to stop GFX FW for GPU recovery.
1. Understand the Problem Clearly
There are different issues people confuse:
| Symptom | Meaning |
|---|---|
| Mac wakes from sleep | Sleep/wake setting, Bluetooth, network, Power Nap, monitor, USB |
| Mac restarts after crash | Kernel panic, watchdog, GPU, driver, hardware |
| Mac starts after shutdown | AutoBoot, power-on event, lid sensor, charger, power button, firmware, hardware |
| Mac shuts down but immediately boots | Firmware/hardware power path, top case, lid sensor, board, display/power issue |
Your problem is specifically:
shutdown โ power off โ automatic power on again
That is different from normal sleep/wake.
2. First Command: Confirm Reboot History
Run:
last reboot | head -20
Example from your Mac:
reboot time Fri May 15 00:39
reboot time Fri May 15 00:17
shutdown time Fri May 15 00:16
reboot time Thu May 14 23:58
shutdown time Thu May 14 23:58
Code language: CSS (css)
Meaning:
The Mac really rebooted multiple times.
This is not just display wake.
Your logs showed repeated reboot/shutdown entries around May 14โ15.
3. Check Scheduled Startup / Restart
Run:
pmset -g sched
If output is empty, there is no scheduled startup/reboot.
In your case:
pmset -g sched
# empty
Code language: PHP (php)
Conclusion:
Scheduled reboot is NOT the cause.
Apple confirms pmset is the command-line utility used to schedule Mac startup, sleep, restart, or shutdown. (Apple Support)
4. Check Power Settings
Run:
pmset -g custom
Or shorter:
pmset -g custom | egrep -i "autorestart|womp|powernap|tcpkeepalive|sleep|disksleep|displaysleep"
Code language: JavaScript (javascript)
Important settings:
| Setting | Meaning |
|---|---|
autorestart | Restart after power failure |
womp | Wake on network access |
powernap | Background wake tasks |
tcpkeepalive | Network keepalive during sleep |
sleep | System sleep timer |
displaysleep | Display sleep timer |
Your output showed:
womp 0
powernap 0
tcpkeepalive 0
pmset -g sched empty
autorestart not set
Code language: JavaScript (javascript)
Conclusion:
Normal power schedule / network wake / Power Nap is not the reason.
Your latest log confirms no scheduled reboot and wake/network-related options were already disabled.
5. Disable Auto Restart After Power Failure
Run:
sudo pmset -a autorestart 0
Check:
pmset -g custom | grep -i autorestart || echo "autorestart not set"
Code language: PHP (php)
If you get:
autorestart not set
Code language: JavaScript (javascript)
or no active autorestart, then this is not the cause.
Your result:
autorestart not set
Code language: JavaScript (javascript)
Conclusion:
pmset autorestart is not causing the reboot.
6. Apple Silicon: Disable Auto Startup on Lid Open / Power Connect
For newer Mac laptops, Apple documents BootPreference, not just the older AutoBoot. Use this on Apple silicon MacBook models.
To prevent startup when opening lid or connecting to power:
sudo nvram BootPreference=%00
Check:
nvram -p | grep -i BootPreference
Expected:
BootPreference %00
Undo later:
sudo nvram -d BootPreference
Apple says sudo nvram BootPreference=%00 prevents startup when opening the lid or connecting to power, and sudo nvram -d BootPreference re-enables automatic startup. (Apple Support)
Older/legacy command sometimes used:
sudo nvram AutoBoot=%00
Check:
nvram -p | grep -i AutoBoot
But for modern Apple silicon MacBooks, prefer:
sudo nvram BootPreference=%00
7. Best Shutdown Test Command
Use this:
sudo shutdown -h now
Meaning:
-h = halt / power off
now = immediately
If Mac still powers on again after this, it is not a normal user restart.
8. Correct Test Order
Do not remove HDMI after shutdown command. Test cleanly.
Test A: With all devices connected
sudo shutdown -h now
If it reboots, continue.
Test B: Remove external monitor / HDMI / USB-C first
Disconnect:
HDMI
USB-C dock
USB hub
external keyboard
external mouse
external SSD
charger, if battery has enough charge
Then run:
sudo shutdown -h now
If it still reboots, external monitor alone is not the only cause.
In your case, you already tested this and it still rebooted.
Conclusion:
External monitor alone is not the full cause.
9. Check Whether macOS Logged a Panic
Run:
sudo find /Library/Logs/DiagnosticReports /var/db/PanicReporter -type f -iname "*panic*" -exec ls -lah {} \; | tail -20
Code language: JavaScript (javascript)
Then check for todayโs panic:
sudo find /Library/Logs/DiagnosticReports /var/db/PanicReporter -type f \( -iname "*panic*" -o -iname "*shutdown*" -o -iname "*reset*" \) -newermt "2026-05-15 00:00" -exec ls -lah {} \;
Code language: JavaScript (javascript)
Your result:
Only old file:
.contents.panic Jan 27
No May 15 panic file
Code language: CSS (css)
Conclusion:
Todayโs reboot was not recorded as a new kernel panic.
Code language: JavaScript (javascript)
But your old panic was important:
AGXk ... Failed to stop GFX FW for GPU recovery
That points to:
GPU / display firmware / graphics path
Your panic file showed Apple GPU-related kernel extensions such as IOGPUFamily and AGXG16X.
10. Read Panic File
Run:
sudo sed -n '1,120p' /Library/Logs/DiagnosticReports/.contents.panic
Code language: JavaScript (javascript)
If unreadable:
sudo strings /Library/Logs/DiagnosticReports/.contents.panic | head -120
Important panic keywords:
| Keyword | Meaning |
|---|---|
AGXk | Apple GPU driver/firmware |
GFX FW | Graphics firmware |
IOGPUFamily | Apple GPU framework |
AGXG16X | Apple GPU kext |
watchdog | System/hardware timed out |
Sleep Wake Failure | Sleep/wake firmware failure |
SOCD | Apple silicon system controller crash |
thermal | overheating / thermal shutdown |
bridgeOS | older Intel T2-related issue |
Your old panic:
AGXk ... Failed to stop GFX FW for GPU recovery
Conclusion:
Old crash was GPU/display firmware related.
11. Check Who Requested Shutdown or Restart
Run:
log show --last 20m --style compact --predicate 'eventMessage CONTAINS[c] "power button" OR eventMessage CONTAINS[c] "lid" OR eventMessage CONTAINS[c] "clamshell" OR eventMessage CONTAINS[c] "wake" OR eventMessage CONTAINS[c] "shutdown" OR eventMessage CONTAINS[c] "restart"' | tail -80
Code language: JavaScript (javascript)
What to look for:
| Log phrase | Meaning |
|---|---|
power button | Power button event |
lid / clamshell | Lid sensor event |
wake | System woke from sleep/off-like state |
shutdown | Shutdown sequence |
restart | Restart command |
Previous shutdown cause | Shutdown reason |
Your log showed mostly:
BT not yet ready
Shutdown sockets
No wake work scheduled
background boot tasks
Conclusion:
No clear app restart request
No power button evidence
No scheduled restart evidence
Your log mainly showed services shutting down/restarting sockets and background tasks, not a user/app-requested restart cause.
12. Check Previous Shutdown Cause
Run:
log show --last 3h --style compact --predicate 'eventMessage CONTAINS[c] "Previous shutdown cause"' | tail -20
Code language: JavaScript (javascript)
If empty:
macOS did not expose a useful shutdown cause.
Your command returned no useful shutdown cause.
13. Check Exact Reboot Window
Replace the time with your real reboot time.
Example:
log show --start "2026-05-15 00:35:00" --end "2026-05-15 00:42:00" --style compact --predicate 'eventMessage CONTAINS[c] "shutdown" OR eventMessage CONTAINS[c] "panic" OR eventMessage CONTAINS[c] "watchdog" OR eventMessage CONTAINS[c] "SOCD" OR eventMessage CONTAINS[c] "thermal" OR eventMessage CONTAINS[c] "restart"' | tail -100
Code language: JavaScript (javascript)
If it shows no panic/watchdog/thermal:
No recorded software crash reason found.
Your exact-window search did not show a new panic or useful shutdown reason for May 15.
14. Check Sleep/Wake Log
Run:
pmset -g log | egrep -i "Wake reason|Sleep Wake Failure|DarkWake|Shutdown|Restart|panic" | tail -80
Code language: JavaScript (javascript)
Exact window:
pmset -g log | awk '/2026-05-15 00:35/,/2026-05-15 00:42/' | egrep -i "sleep|wake|darkwake|panic|shutdown|restart|failure"
Code language: JavaScript (javascript)
If exact window gives nothing useful:
It was probably not a normal sleep/wake event.
Your exact sleep/wake window produced no useful entries.
15. Check Display Status
Run:
system_profiler SPDisplaysDataType | egrep -i "Chipset|Display|Resolution|Main Display|Online|Connection|Display Type"
Code language: JavaScript (javascript)
Your output:
Chipset Model: Apple M4 Pro
External display: 1920 x 1080, Main Display: Yes, Online: Yes
Built-in Liquid Retina XDR Display
Resolution: 3456 x 2234 Retina
Online: Yes
Connection Type: Internal
Meaning:
macOS thinks internal display is online.
But physically you cannot see it.
This is very important.
Conclusion:
Internal display panel / cable / backlight / display path issue is very likely.
16. Check Lid Sensor
Run:
ioreg -r -k AppleClamshellState -d 4 | grep AppleClamshellState
Expected:
Open lid = No
Closed lid = Yes
To test live:
while true; do ioreg -r -k AppleClamshellState -d 4 | grep AppleClamshellState; sleep 2; done
Code language: JavaScript (javascript)
Then slowly close/open lid.
Stop:
Control + C
Meaning:
| Result | Meaning |
|---|---|
Changes No โ Yes | Lid sensor likely works |
Always No | Lid sensor/top-case issue |
Always Yes | Lid sensor thinks lid closed |
| Random changes | Lid sensor/cable/magnet issue |
Your current result:
AppleClamshellState = No
That means lid is currently detected open. You still need close/open test to confirm sensor changes.
17. Reset Power Settings
Run:
sudo pmset restoredefaults
Then test:
sudo shutdown -h now
This resets custom power settings.
Use when:
power settings are messy
sleep/disksleep warnings appear
many pmset changes were tested
18. Strong Test: Disable Sleep Temporarily
This is for testing only.
sudo pmset -a sleep 0 displaysleep 0 disksleep 0 autorestart 0 womp 0 powernap 0 tcpkeepalive 0
Then:
sudo shutdown -h now
If still reboots:
Not normal sleep setting.
Restore later:
sudo pmset restoredefaults
or:
sudo pmset -a sleep 30 displaysleep 10 disksleep 10
19. Safe Mode Test
For Apple silicon Mac:
- Shut down.
- Press and hold power button until startup options appear.
- Select your disk.
- Hold Shift.
- Click Continue in Safe Mode.
Apple says Apple silicon Safe Mode is started from startup options by holding Shift while choosing the startup volume. (Apple Support)
Then run:
sudo shutdown -h now
Result:
| Safe Mode result | Meaning |
|---|---|
| Shutdown works | third-party software/driver/login item may be involved |
| Still reboots | hardware/firmware/power path likely |
20. Apple Diagnostics
For Apple silicon Mac:
- Shut down.
- Press and hold power button until startup options appear.
- Press:
Command + D
Appleโs startup options screen supports opening Apple Diagnostics using Command-D. (Apple Support)
If you get an error code, save it.
Common useful codes may point to:
display
battery
logic board
memory
storage
power
sensor
If Diagnostics says no issue but problem continues, that does not fully clear hardware. Intermittent display/power issues may not always appear.
21. Recovery Mode Test
For Apple silicon:
- Shut down.
- Hold power button until startup options.
- Choose Options.
- Continue into Recovery.
Apple documents Recovery on Apple silicon as holding the power button until volumes and Options appear. (Apple Support)
From Recovery, use Terminal:
shutdown -h now
Result:
| Recovery shutdown result | Meaning |
|---|---|
| Stays off | installed macOS/userspace may be involved |
| Reboots again | firmware/hardware more likely |
22. Reinstall macOS Test
Do this only after backup.
Apple recommends software updates, Safe Mode, reinstalling macOS, and checking hardware when a Mac restarts because of a problem. (Apple Support)
Use this when:
No clear panic
No schedule
No third-party cause
Safe Mode changes behavior
System files may be broken
But in your case, because internal display is already physically not visible, reinstall may not solve the root issue.
23. Hardware Scenario Matrix
Scenario A: Scheduled reboot
Commands:
pmset -g sched
If output has schedule:
sudo pmset repeat cancel
Conclusion:
Scheduled startup/restart caused issue.
Your case:
No schedule.
Scenario B: Wake on network / Power Nap
Commands:
pmset -g custom | egrep -i "womp|powernap|tcpkeepalive"
Code language: JavaScript (javascript)
Fix:
sudo pmset -a womp 0 powernap 0 tcpkeepalive 0
Your case:
Already disabled.
Scenario C: Auto restart after power failure
Command:
pmset -g custom | grep -i autorestart || echo "autorestart not set"
Code language: PHP (php)
Fix:
sudo pmset -a autorestart 0
Your case:
autorestart not set.
Code language: JavaScript (javascript)
Scenario D: Auto startup when lid opens / charger connects
Modern Apple silicon fix:
sudo nvram BootPreference=%00
Check:
nvram -p | grep -i BootPreference
Undo:
sudo nvram -d BootPreference
Apple documents BootPreference=%00 for preventing startup when lid opens or power connects. (Apple Support)
Scenario E: App requests restart
Command:
log show --last 30m --style compact --predicate 'eventMessage CONTAINS[c] "restart" OR eventMessage CONTAINS[c] "reboot" OR eventMessage CONTAINS[c] "logout" OR eventMessage CONTAINS[c] "shutdown"' | tail -100
Code language: JavaScript (javascript)
If you see app/updater:
Disable that app auto update
Quit app fully
Remove login item
Reinstall app
Your earlier VS Code ShipIt updater was noisy, but later shutdown still rebooted after VS Code isolation, so it is not final root cause.
Scenario F: Kernel panic
Commands:
sudo find /Library/Logs/DiagnosticReports /var/db/PanicReporter -type f -iname "*panic*" -exec ls -lah {} \; | tail -20
Code language: JavaScript (javascript)
Read latest:
sudo strings /path/to/latest.panic | head -120
If panic contains GPU:
AGXk
IOGPUFamily
AGXG16X
GFX FW
Suspect:
GPU/display firmware
internal display path
external monitor/dock
macOS graphics bug
logic board/display hardware
Your old panic was GPU/display related.
Scenario G: Sleep Wake Failure
Command:
sudo find /Library/Logs/DiagnosticReports /var/db/PanicReporter -type f -iname "*Sleep Wake Failure*" -exec ls -lah {} \; | tail -20
Code language: JavaScript (javascript)
Fix attempts:
sudo pmset restoredefaults
sudo pmset -a powernap 0 tcpkeepalive 0 womp 0
Also remove:
USB-C dock
external display
external SSD
Bluetooth devices
Scenario H: Display detected but black
Command:
system_profiler SPDisplaysDataType | egrep -i "Display Type|Main Display|Online|Connection|Resolution"
Code language: JavaScript (javascript)
If internal display says:
Online: Yes
Connection Type: Internal
but screen is black:
Display assembly / display cable / backlight / display power path issue
Your case exactly matches this.
Scenario I: Lid sensor issue
Command:
while true; do ioreg -r -k AppleClamshellState -d 4 | grep AppleClamshellState; sleep 2; done
Code language: JavaScript (javascript)
Expected:
Open lid = No
Closed lid = Yes
If it does not change:
lid sensor / magnet / top case / display assembly issue
Code language: PHP (php)
Scenario J: Power button / top case issue
Symptoms:
Mac powers on immediately after shutdown
No schedule
No panic
No AutoBoot reason
No app restart
Possible cause:
Power button signal stuck/intermittent
Keyboard/top case issue
Touch ID/power button hardware issue
Code language: JavaScript (javascript)
Test:
log show --last 20m --style compact --predicate 'eventMessage CONTAINS[c] "power button"' | tail -50
Code language: JavaScript (javascript)
If logs show power button events without pressing it:
top case / power button issue likely
Code language: PHP (php)
If no logs show it, hardware can still be faulty at low firmware level.
Scenario K: Logic board power-management issue
Symptoms:
Mac reboots after real halt
No panic
No schedule
No app restart
No peripheral cause
Auto-start disabled
Internal display already faulty
Likely service items:
logic board
power management circuit
display power rail
USB-C/power controller
sensor path
This is not command-fixable.
24. Your Case: Final Diagnosis Based on Evidence
Evidence 1: No scheduled reboot
pmset -g sched empty
Code language: PHP (php)
Conclusion:
Not scheduled startup/restart.
Evidence 2: Wake/network options off
womp 0
powernap 0
tcpkeepalive 0
Conclusion:
Not normal network wake / Power Nap.
Evidence 3: No new May 15 panic
Only old .contents.panic from Jan 27
No May 15 panic found
Code language: CSS (css)
Conclusion:
Current shutdownโreboot is not recorded as a new kernel panic.
Code language: JavaScript (javascript)
Evidence 4: Old panic is GPU/display firmware
AGXk ... Failed to stop GFX FW for GPU recovery
Conclusion:
There is history of GPU/display firmware crash.
Evidence 5: Internal display is detected online but not visible
Built-in Liquid Retina XDR Display
Online: Yes
Connection Type: Internal
Conclusion:
Internal display panel/cable/backlight/display path issue is very likely.
Evidence 6: Shutdown still reboots without HDMI
Conclusion:
External monitor alone is not the full cause.
Final likely root cause
Hardware / firmware power-on issue connected to internal display path, lid/top-case sensor path, or logic board power management.
Code language: JavaScript (javascript)
Most likely order:
1. Internal display assembly / display cable / backlight
2. Lid sensor / display-lid sensor path
3. Power button / top case
4. Logic board power-management circuit
Code language: JavaScript (javascript)
25. Direct Fix Commands to Try Before Service
Run this full software-side reset:
sudo pmset restoredefaults
sudo pmset -a autorestart 0 womp 0 powernap 0 tcpkeepalive 0
sudo nvram BootPreference=%00
Check:
pmset -g sched
pmset -g custom | egrep -i "autorestart|womp|powernap|tcpkeepalive|sleep"
nvram -p | grep -i BootPreference
Code language: JavaScript (javascript)
Then shut down:
sudo shutdown -h now
If still reboots:
Stop software debugging.
Move to hardware/service.
26. What to Tell Apple Service
Use this exact message:
My MacBook Pro shuts down but automatically powers on/reboots again after shutdown.
I tested:
- sudo shutdown -h now
- pmset schedule is empty
- autorestart is not set
- womp, powernap, tcpkeepalive are disabled
- no new panic file was generated for the latest reboot
- external monitor/HDMI was removed before shutdown, but issue still happens
Important display symptom:
- Built-in display is physically not visible/working
- macOS still detects the built-in Liquid Retina XDR display as Online and Internal
- External monitor is used as the main display
Old panic report shows:
AGXk ... Failed to stop GFX FW for GPU recovery
Please check:
- internal display panel/cable/backlight path
- lid sensor / clamshell sensor
- power button/top case
- logic board power-management/display power path
Code language: PHP (php)
Before service, Apple recommends backing up the Mac because service may require erasing or replacing the startup disk. (Apple Support)
27. One-Page Quick Command Sheet
Reboot history
last reboot | head -20
Scheduled startup/reboot
pmset -g sched
Power settings
pmset -g custom | egrep -i "autorestart|womp|powernap|tcpkeepalive|sleep|disksleep|displaysleep"
Code language: JavaScript (javascript)
Disable power wake options
sudo pmset -a autorestart 0 womp 0 powernap 0 tcpkeepalive 0
Disable Apple silicon auto startup on lid/power
sudo nvram BootPreference=%00
Undo BootPreference
sudo nvram -d BootPreference
Real shutdown test
sudo shutdown -h now
Find panic files
sudo find /Library/Logs/DiagnosticReports /var/db/PanicReporter -type f -iname "*panic*" -exec ls -lah {} \; | tail -20
Code language: JavaScript (javascript)
Find todayโs panic/shutdown/reset files
sudo find /Library/Logs/DiagnosticReports /var/db/PanicReporter -type f \( -iname "*panic*" -o -iname "*shutdown*" -o -iname "*reset*" \) -newermt "2026-05-15 00:00" -exec ls -lah {} \;
Code language: JavaScript (javascript)
Read panic
sudo strings /Library/Logs/DiagnosticReports/.contents.panic | head -120
Display detection
system_profiler SPDisplaysDataType | egrep -i "Display Type|Main Display|Online|Connection|Resolution"
Code language: JavaScript (javascript)
Lid sensor
ioreg -r -k AppleClamshellState -d 4 | grep AppleClamshellState
Live lid sensor test
while true; do ioreg -r -k AppleClamshellState -d 4 | grep AppleClamshellState; sleep 2; done
Code language: JavaScript (javascript)
Logs for shutdown/restart/power button
log show --last 20m --style compact --predicate 'eventMessage CONTAINS[c] "power button" OR eventMessage CONTAINS[c] "lid" OR eventMessage CONTAINS[c] "clamshell" OR eventMessage CONTAINS[c] "wake" OR eventMessage CONTAINS[c] "shutdown" OR eventMessage CONTAINS[c] "restart"' | tail -80
Code language: JavaScript (javascript)
Reset power settings
sudo pmset restoredefaults
28. Final Practical Conclusion
For your Mac, based on all collected evidence:
The reboot-after-shutdown issue is very unlikely to be caused by VS Code, app updater, Power Nap, scheduled reboot, Wake-on-LAN, or a normal macOS sleep setting.
The strongest diagnosis is:
Hardware/firmware power issue related to the internal display path, lid/top-case sensor path, or logic board power management.
Code language: JavaScript (javascript)
The biggest red flag is:
Internal display is detected Online by macOS, but physically it does not work.
Combined with your old GPU panic:
AGXk ... Failed to stop GFX FW for GPU recovery
the repair priority should be:
1. Internal display assembly / display cable / backlight path
2. Lid sensor / clamshell sensor
3. Power button / top case
4. Logic board power-management/display power circuit
Code language: JavaScript (javascript)
Commands can confirm and reduce false causes, but if sudo shutdown -h now still reboots after BootPreference=%00, autorestart 0, no schedule, no peripherals, and no new panic, then this is no longer a normal software fix.
Iโm a DevOps/SRE/DevSecOps/Cloud Expert passionate about sharing knowledge and experiences. I have worked at Cotocus. I share tech blog at DevOps School, travel stories at Holiday Landmark, stock market tips at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at TrueReviewNow , and SEO strategies at Wizbrand.
Do you want to learn Quantum Computing?
Please find my social handles as below;
Rajesh Kumar Personal Website
Rajesh Kumar at YOUTUBE
Rajesh Kumar at INSTAGRAM
Rajesh Kumar at X
Rajesh Kumar at FACEBOOK
Rajesh Kumar at LINKEDIN
Rajesh Kumar at WIZBRAND
Find Trusted Cardiac Hospitals
Compare heart hospitals by city and services โ all in one place.
Explore Hospitals