Use
InteropServices
namespace in your code as
using System.Runtime.InteropServices;
then declare
[DllImport("user32.dll")]
public static extern int ExitWindowsEx(int uFlags, int dwReason);
and then use ExitWindowEx with appropriate parameter as event where you want to shutdown your system
ExitWindowsEx(1, 0);