- How to Fix When Windows Won’t Shut Down
- Force Shut Down The Computer
- Use Command Prompt To Shut Down Windows
- Create a Batch File To Shut Down Windows
- Use The Run Box To Shut Down Windows
- Quit The Open Apps And Kill Processes To Shut Down The Computer
- Disable Fast Startup To Fix Windows Shutdown Issue
- Reboot Your Windows Computer Instead
- Use the Troubleshooter When Windows Won’t Shut Down
- Detect windows shutting down service
- Answered by:
- Question
- Answers
- All replies
- Detect windows shutting down service
- Answered by:
- Question
- Answers
- All replies
How to Fix When Windows Won’t Shut Down
One of these solutions will do the trick
Unless you have an issue on your computer, your Windows computer should shut down with the click of an option. If Windows won’t shut down despite repetitive attempts, there’s probably a problematic element on your machine.
Sometimes it’s a bit tricky to find out exactly what’s causing the Windows shut down issue on your computer. It may be an app, a system issue, or something else. Regardless, there are multiple methods you can try and apply and one of these should likely fix the issue for you.
Force Shut Down The Computer
If the normal Start Menu shut down option doesn’t work for you and Windows’s won’t shut down, you may need to use the force shutdown method. It forces your computer to turn off regardless of what state it is in.
On most computers, all you need to do to force shut down the computer is to press and hold down the Power button for a few seconds. Keep it held down until you see your machine powering off.
Once that is done, you can press the same Power key to turn your machine back on.
Windows provides you with multiple ways to shut down a computer. If the one that you normally use doesn’t work, you can always try a different method to turn your computer off.
Use Command Prompt To Shut Down Windows
One of the common ways to shut down a Windows computer is to use a command in the Command Prompt utility. Execute a single-line command and it’ll make sure to power your machine off.
- Use the search box to search for Command Prompt and click on it when it appears in the search results.
- When it opens, type in the following command and press Enter. Make sure you’ve saved your work in your apps before running the command.
- Your computer will immediately turn off.
Create a Batch File To Shut Down Windows
If the above method successfully turned off your computer, you’ll want to stick to it to shut down your machine whenever you want. You can actually save yourself from the hassle of typing in the command every time by creating a batch file.
You can then turn off your computer with a single-click.
- Use the Cortana search box to search for Notepad and click on it when you see it.
- You’ll use the same command you used in the Command Prompt utility in Notepad. Type in the following command.
- Click on the File menu at the top and select the Save option. You’ll be saving it as an executable batch file on your PC.
- On the following screen, choose your Desktop as the location to save the file. It’ll be easier for you to run the file from your Desktop than anywhere else.
- Enter a name for your file followed by a dot and then bat. It should look something like shutdown.bat.
- From the Save as type box, choose All Files as you don’t want to save it as a text file.
- Then click on the Save button to save the file.
- You can right-click on the file and select Run as administrator to shutdown your PC. This step can also be eliminated by setting the file to always run as admin.
- Right-click on the file and select Send to followed by Desktop. It’ll create a shortcut on your Desktop.
- Right-click on the newly created shortcut and select Properties.
- Make sure you’re inside the Shortcut tab. Then find and click on the Advanced button.
- Checkmark Run as administrator and click on OK.
You can double-click on the file each time you want to turn off your computer.
Use The Run Box To Shut Down Windows
You can use the above command in the Run box as well.
- Press the Windows + R keys at the same time.
- Type in the following command and hit Enter.
shutdown /s /f /t 0
Quit The Open Apps And Kill Processes To Shut Down The Computer
One of the possible reasons Window’s won’t shut down is because you have certain apps open on your machine. Closing them all should likely fix the issue for you.
- Right-click on your taskbar at the bottom and select Task Manager.
- Go to the Processes tab if you aren’t already there. Select each process that you identify as an app and click on the End task button. You need to do it for each process in the list.
It’ll close the app by killing its process. You can then use the standard shutdown method to shut down your computer.
Disable Fast Startup To Fix Windows Shutdown Issue
Fast Startup is one of the features involved with your computer’s boot-up process. Disabling it might resolve the issue for you.
- Launch Control Panel and select the Power Options option.
- Select Choose what the power button does in the left sidebar.
- Untick the option that says Turn on fast startup (recommended), and click Save changes at the bottom.
You may now try shutting down your computer to see if it works.
Reboot Your Windows Computer Instead
If shutting down doesn’t work, you can try rebooting your computer instead. Once it reboots, you can try to shut down your machine.
- Click on the Start Menu icon, select the power icon, and choose Restart.
Use the Troubleshooter When Windows Won’t Shut Down
Lastly, if nothing works, you can troubleshoot the issue with Windows Troubleshooter.
- Open the Settings app and click on Update & Security.
- Select Troubleshoot in the left sidebar, click on Power on the right-hand side pane, and choose Run the troubleshooter.
- Let the troubleshoot run, detect issues, and offer you possible fixes to those issues.
Your Windows shutdown issue should be gone once you’ve applied the recommended fixes.
Mahesh has been obsessed with technology since he got his first gadget a decade or so ago. Over the last few years, he’s written a number of tech articles on various online publications including but not limited to MakeTechEasier and Android AppStorm. Read Mahesh’s Full Bio
Detect windows shutting down service
This forum has migrated to Microsoft Q&A. Visit Microsoft Q&A to post new questions.
Answered by:
Question
This code detect when a user restarts Windows but does not fire when user does normal windows Shutdown.
const int SERVICE_ACCEPT_PRESHUTDOWN = 0x100;
const int SERVICE_CONTROL_PRESHUTDOWN = 0xf;
FieldInfo acceptedCommandsFieldInfo =
typeof(ServiceBase).GetField(«acceptedCommands», BindingFlags.Instance | BindingFlags.NonPublic);
if (acceptedCommandsFieldInfo == null)
<
string errormsg = «acceptedCommands field not found»;
System.IO.File.WriteAllText(@»e:\\WriteerrText.txt», errormsg);
>
int value = (int)acceptedCommandsFieldInfo.GetValue(this);
acceptedCommandsFieldInfo.SetValue(this, value | SERVICE_ACCEPT_PRESHUTDOWN);
InitializeComponent();
protected override void OnCustomCommand(int command)
<
if (command == SERVICE_CONTROL_PRESHUTDOWN)
<
Answers
I’m not aware of any issues with shut down. A restart is basically just a shut down followed by a power on. In newer OSes the restart is a little different but I’m not aware of anyone having issues with shut down.
Having said that, a couple of things come to mind. Firstly services are on the clock. If they don’t respond fast enough then things go awry. For a shutdown you have 20 seconds, by default. For a reboot it is longer (500 seconds in Windows 10). Hence if your shutdown is taking too long it might fail on shutdown but not on a reboot.
The other thing that comes to mind is that, maybe, your machine isn’t actually shutting down. If you’re clicking the Shut Down option in the Power menu then it likely is. But starting with Win 8 we have fast boot which could be changing the shut down request to hibernate or something. I’ve never looked at the shutdown behavior of services in this mode so I cannot confirm.
All replies
If your service runs on the computer being shut down, it get’s the proper order to close. Wich it should do in a speedy fashion. If you service design requires that you differentiate between ending of service due to shutdown or reboot, the design might be faulty.
There is no reliable way to differentiate between the two. After all a user could just power down via ACPI event (pressing the power button) at the start of the boot sequence. And now a reboot turned into a shutdown.
Or what if a update breaks the boot routine, resulting in it not restarting no mater how hard it tries?
You should always asume that every time the windows shuts down, it will stay shut down.
If you service only saves on stuff like shutdown, there is a serious design problem. After all what if the windows crashes or the user pulls the power cord? If you service works with the network, the network connection might terminate at any moment. Your service must be designed around those possibilities.
If this is about differentiating this from another computer, I am pretty sure the windows logs have some indication when Windows was shutdown/started and if a instant reboot was supposed to happen after the reboot. But again, intention of reboot does not mean a guaranteed reboot.
Detect windows shutting down service
This forum has migrated to Microsoft Q&A. Visit Microsoft Q&A to post new questions.
Answered by:
Question
This code detect when a user restarts Windows but does not fire when user does normal windows Shutdown.
const int SERVICE_ACCEPT_PRESHUTDOWN = 0x100;
const int SERVICE_CONTROL_PRESHUTDOWN = 0xf;
FieldInfo acceptedCommandsFieldInfo =
typeof(ServiceBase).GetField(«acceptedCommands», BindingFlags.Instance | BindingFlags.NonPublic);
if (acceptedCommandsFieldInfo == null)
<
string errormsg = «acceptedCommands field not found»;
System.IO.File.WriteAllText(@»e:\\WriteerrText.txt», errormsg);
>
int value = (int)acceptedCommandsFieldInfo.GetValue(this);
acceptedCommandsFieldInfo.SetValue(this, value | SERVICE_ACCEPT_PRESHUTDOWN);
InitializeComponent();
protected override void OnCustomCommand(int command)
<
if (command == SERVICE_CONTROL_PRESHUTDOWN)
<
Answers
I’m not aware of any issues with shut down. A restart is basically just a shut down followed by a power on. In newer OSes the restart is a little different but I’m not aware of anyone having issues with shut down.
Having said that, a couple of things come to mind. Firstly services are on the clock. If they don’t respond fast enough then things go awry. For a shutdown you have 20 seconds, by default. For a reboot it is longer (500 seconds in Windows 10). Hence if your shutdown is taking too long it might fail on shutdown but not on a reboot.
The other thing that comes to mind is that, maybe, your machine isn’t actually shutting down. If you’re clicking the Shut Down option in the Power menu then it likely is. But starting with Win 8 we have fast boot which could be changing the shut down request to hibernate or something. I’ve never looked at the shutdown behavior of services in this mode so I cannot confirm.
All replies
If your service runs on the computer being shut down, it get’s the proper order to close. Wich it should do in a speedy fashion. If you service design requires that you differentiate between ending of service due to shutdown or reboot, the design might be faulty.
There is no reliable way to differentiate between the two. After all a user could just power down via ACPI event (pressing the power button) at the start of the boot sequence. And now a reboot turned into a shutdown.
Or what if a update breaks the boot routine, resulting in it not restarting no mater how hard it tries?
You should always asume that every time the windows shuts down, it will stay shut down.
If you service only saves on stuff like shutdown, there is a serious design problem. After all what if the windows crashes or the user pulls the power cord? If you service works with the network, the network connection might terminate at any moment. Your service must be designed around those possibilities.
If this is about differentiating this from another computer, I am pretty sure the windows logs have some indication when Windows was shutdown/started and if a instant reboot was supposed to happen after the reboot. But again, intention of reboot does not mean a guaranteed reboot.