Siri and Terminal can help you when the GUI of your M-series Mac freezes
One of the most frustrating experiences of using any computer is when the graphical user interface (GUI) becomes unresponsive. Apple users know that their computers are not immune to this problem. A forced shutdown (by holding down the power button) should be your last resort. Instead, there is another option to try.
Launch Siri. Depending on your system configuration, you may be able to say, “Hey, Siri,” though you will also need to make sure no other Apple devices are in the vicinity to hear you. Instead, you can configure a hotkey to launch the voice assistant. Typically, that defaults to the F5 key.
Once Siri is active, as evident by the glowing sphere in the upper right corner of the screen, say, “Launch Terminal.” For those unfamiliar, Terminal is a text-based app allowing users to enter direct system commands.
The Terminal app window should launch. The first line displayed should show the date and time of last use. The next line should begin with your username followed by the system name. Then you should see a tilde (~) followed by the percentage (%) symbol and a flashing cursor.
Type the following exactly.
sudo shutdown -r now
The -r flag indicates that you want the system to reboot. Alternatively, you can use the -h flag (halt) for a full shutdown.
The now flag means you want the task of system rebooting to happen, well, now. If you some reason you would rather delay the shutdown, you can use a different time flag. For example, +60 would tell the system to shut down in 60 minutes. Or you could even specify a specific time and date for the action.
sudo shutdown -r 2308151745
In the example above, the system would be told to reboot on August 15, 2023, at 5:45 p.m. (I am not sure why you would ever want to enter such a command, but at least you know you can.)
Apple has a handy guide to all the ins and outs of Terminal available on their website here.