Please read these:



I asked the first and the Github issue was created by somebody else, quoting my SE question.

They claim that Windows 10 is broken and that shutdown /s doesn't send the "close" signal to running programs. But can this really be true? It seems too stupid to be real. And it must have changed recently in Windows 10 if so?

Naturally, since I don't use the /f flag to force immediate shutdown, I want the command to do exactly what the start menu does when the user shuts down the machine that way. But this shutdown command seems to just visually notify the user (which is useless), but not send any signal to the running programs, and just immediately shut down when its internal timeout (one minute?) is up.

Is this a bug in Windows 10 or Bitcoin Core? The Bitcoin Core developers seem convinced that it's Windows' fault, but that's always FOSS developers' stance, and it seems like something very strange for MS to randomly break in a minor update?

  • You can use "shutdown /s /f /t x", where x = an integer, to force a timeout in x seconds instead of the default 60s. Additionally, any number above 0 will imply "/f", so your command for a quick cmd shutdown can be "shutdown /s /t 1". The "Windows will shut down in less than a minute" banner will show for ~ 1 second, then shut down.
    – Guy S
    Oct 4, 2020 at 7:49

4 Answers 4


shutdown /s does not send the close message to applications because it is not its job to do so. The command simply initiates the normal Windows shutdown procedure which does whatever is necessary.

Sending a close message wouldn't be very effective anyway. This is the same message that an application would receive when you click the close button on the applications window. It can handle this in any way it wishes.

It could shut down the application. This is the default action if no specific action is taken. But applications often intercept this message. It could prompt the user to save any open files or do this itself. It could minimize the application to the notification area. It could ask the user to confirm the shutdown. Or it could do nothing at all.

What Windows does do is send all applications a message that Windows is about to shut down and they should do whatever is necessary. Typically the application would do whatever clean-up action is necessary and then close. If the application ignores this message, or does not reply in a timely manner, the session will end. At this point there is no way for an application to stop the process.

From the information provided there is no reason to suspect a Windows problem. Not sending this message would have major consequences and would have been caught early in testing. I strongly suspect this is an application problem. Applications do not get nearly the same level of testing as does Windows.

  • 8
    Simply put, it's a different message. Instead of each window receiving a WM_CLOSE message when the system is shutting down, each window will get a WM_QUERYENDSESSION message, followed by a WM_ENDSESSION message. So, applications are still notified of a pending shutdown and can react accordingly, whether that system shutdown is initiated by shutdown /s or any other route. See also: docs.microsoft.com/en-us/previous-versions/windows/desktop/… and devblogs.microsoft.com/oldnewthing/20080421-00/?p=22663 Oct 4, 2020 at 3:10
  • 6
    Compare and contrast bitcoin's code with the correct way to handle these messages (furthermore).
    – JdeBP
    Oct 4, 2020 at 6:33
  • It's curious that you say shutdown /s "simply initiates the normal Windows shutdown procedure which does whatever is necessary", when several people here are reporting different behaviour between shutdown /s and normal (Start menu) shutdown.
    – Reg Edit
    Oct 4, 2020 at 18:08
  • @CodyGray Note however that the claim on the Github thread is not that Windows is failing to send WM_CLOSE but that it is failing to send WM_QUERYENDSESSION. Oct 5, 2020 at 1:21
  • @HarryJohnston I think perhaps you meant to reply to JdeBP instead of me? I didn't link or mention a GitHub thread. Mar 26, 2022 at 6:08

Generally shutdown /s does not send any "close" messages. It call one of few Win32 API functions for shutting down Windows system.

These functions in turn notify aplications about shutdown/restart event via WM_QUERYENDSESSION and WM_ENDSESSION messages.

Programs can then agree or try to prevent pending shutdown by responsing properly to WM_QUERYENDSESSION, eg. for stopping cleanly, etc.

So, in theory after issue shutdown /s command, there is some "close" messages send to all programs and you don't need doing anything special for that.

But shutdown /s is somehow specific (or buggy?), and makes Windows ignore responses for WM_QUERYENDSESSION so Bitcoin Core cannot shut down in a clean way. I see this behaviour on Windows 7, and as appears from linked GitHub issue Windows 10 has it too.

One answer here suggests that more "normal" (like from start menu) shutdown is performed via PowerShell Stop-Computer command.

At an API level, shutdown /s will be using one of the InitiateShutdown APIs (I'm not sure which one) whereas Stop-Computer most likely uses ExitWindowsEx. The latter is more appropriate when run from an interactive session.

Personally I never trust Windows in such scenarios and stops any important programs manually. I even read some article about Windows killing apps if they do clean-up for too long, but I cannot find it now.

You can read about shutdown procedure here.

And if you want there is a gist which I used for testing.


The command shutdown /s issues a forced reboot, as described in the output of shutdown /?:

/t xxx Set the time-out period before shutdown to xxx seconds. The valid range is 0-315360000 (10 years), with a default of 30. If the timeout period is greater than 0, the /f parameter is implied.

/f Force running applications to close without forewarning users.

[Abridged, emphasis mine.]

If you want applications to be able to cancel the shutdown, you need to use shutdown /s /t 0 instead.

This doesn't explain why the behaviour you observe has changed, however. I'm not sure whether the behaviour of Windows has changed or there has been a change in the Bitcoin application.

I do note that the code here appears to me to be incorrect (as pointed out by JdeBp in the comments to another answer) and appears to be depending entirely on ShutdownBlockReasonCreate, which presumably the forced shutdown overrides. I believe that if the code waited until the client shutdown was complete before responding to the WM_ENDSESSION message, then the client shutdown would be allowed to complete, provided it took no more than five seconds to do so.

  • ... it is also entirely possible that the forced reboot simply kills all the user's applications outright, I'm not sure. I can confirm that shutdown /s has behaved in this way at least as far back as Windows 8.1. Oct 4, 2020 at 20:40
  • Harry Johnston thanks for this insight. It seems to me to verge on the criminal that this is by design, but it explains a lot :)
    – Reg Edit
    Oct 4, 2020 at 22:31

The short answer is no, it's not true that Windows shuts down without notifying programs when you use shutdown /s.

EDIT: as pointed out in Harry Johnston's answer, that actually depends on whether you allow a timeout. I always use shutdown /s /t 0 (timeout 0 seconds), since the default is 30 seconds and I don't want to wait a while before anything happens! Incredible as it sounds though, using (or defaulting to) any timeout period is inextricably linked to horrifying save behaviour: Windows will actually then force-terminate your processes without offering you the chance to intervene! And this horrifying behaviour is even by design! (See the usage output from shutdown /?.) My answer is for shutdown /s /t 0, meaning you are not expecting to sit there for up to 30 seconds before anything happens.

You may demonstrate for yourself that Windows notifies programs. Just edit a text file in Notepad, and before saving your changes, issue shutdown /s /t 0. When the shutdown starts, Notepad prevents it, showing that it has received the notification from Windows:

enter image description here

If you then press Cancel (or if you take no action), you are returned to your Windows Desktop, where Notepad can be seen prompting for save:

enter image description here

However, it may be that recent changes in Windows shutdown have introduced a more subtle bug: in what I believe is an attempt to mitigate its annoying shutdowns for updates, Windows has relatively recently acquired the habit of attempting to restore my programs from last time, a feature that doesn't work too well and which I detest, and so I always use shutdown /s /t 0 and shutdown /r /t 0 instead of the Start menu (because thankfully that bypasses the program restore bit). But recently I've noticed that on launching Chrome, it often now reports that it was shut down incorrectly, which does support the idea that Windows has acquired a defect in this area:

enter image description here

But I've never seen a complete failure to notify running apps that would fail the above Notepad test, not in any version of Windows. For information, this is my current version of Windows, as reported by WinVer (I've heard of general problems in version 2004 so I am not moving to that yet):

enter image description here

  • 3
    As a quick test I did exactly what you say: notepad, text, then type the command. Windows did shut down without Notepad prompting to save changes. Interesting you have a different behaviour. Oct 3, 2020 at 11:36
  • @user1532080 yeah that is weird. I've added pics to my answer. What version info does WinVer give you?
    – Reg Edit
    Oct 3, 2020 at 11:58
  • Version 1903 (OS Build 18362.1082). So mine's older... Oh well, I've clicked a button, it's now upgrading to 2004. We'll see then. Oct 3, 2020 at 12:07
  • @user1532080 Good luck with 2004... :) I guess it's been well, 6 months now, so hopefully they've fixed the issues there were when it first came out. btw I was having trouble adding the pics but they are all there now.
    – Reg Edit
    Oct 3, 2020 at 12:11
  • 1
    Thanks! Taskbar and start menu now have a transparent background :D Anyway, did the same test, same behaviour (iow no notification of Notepad). Version 2004 (19041.508). Oct 3, 2020 at 13:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .