@MiPakTeh , based on my research, It is hard to use to c# code to skip all the windows that mention saving file.
However, I find a workaround to set Registry to shut down the computer directly.
First, Please Open Registry and Go to HKEY_USERS.DEFAULT\Control Panel\Desktop.
Second, Please click Edit > New > String Value.
Third, Please Give it the name AutoEndTasks and set Value data to 1 and click OK.
Finally, Please restart your computer to save the effect.
Based on my test, after I execute the above steps, I can use the code to shut down the computer directly.
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.