Do this (-l to log out, -r to reboot, etc.):
String shutdownCmd = "shutdown -l" Process child = Runtime.getRuntime().exec(shutdownCmd);
or (0 to exit the system),
String shutdownCmd = "rundll32.exe shell32.dll,SHExitWindowsEx 0" Process child = Runtime.getRuntime().exec(shutdownCmd);
source share