On Windows 11 (or if you are still running Windows 10), you can use these three ways to find out why the computer shut down unexpectedly using the system event logs.
How to Shut Down a Computer
Windows 10 Is Not Shutting Down? Here's How to Fix It! - EaseUS
SOLVED] PC Randomly Turns Off - What to Do? — Auslogics Blog
Random Shutdowns on Windows 11 Keep Popping up? Fix Guide
Simple Ways to Cancel Auto Shutdown in Windows 10: 15 Steps
How to schedule a shutdown in Windows 10 - IONOS CA
Simple Ways to Cancel Auto Shutdown in Windows 10: 15 Steps
Windows 11 Won't Restart? 5 Ways to Fix it
10 Ways to Shut Down and Restart a Windows 11 PC
How to Fix It When Windows 11 Won't Shut Down
How to Shut Down or Restart Windows 11
How to Fix “Getting Windows Ready” Stuck For Windows 10 & 11