After you complete the steps, you can double-click to run the script and configure the computer to shutdown automatically. Although the power settings don't include an option to turn off a device ...
the same problem can cause a sudden shutdown. That is why it is recommended to check if your UPS is fully functioning. There could be numerous reasons why your computer can turn itself off at times.