Windows – Does “shutdown /s” really not send the “close” signal to running applications? If so, why? And how to make it do so

shutdownwindows 10

Please read these:

https://bitcoin.stackexchange.com/questions/99273/why-has-bitcoin-core-stopped-shutting-down-when-windows-cleanly-shuts-down

https://github.com/bitcoin/bitcoin/issues/20052

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?

Best Answer

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.

Related Question