April 14th, 2020
like1 reaction

If one program blocks shutdown, then all programs block shutdown

We’re all in this together, as far as the Blocked Shutdown Resolver (BSDR) is concerned.

If a program blocks the WM_QUERY­END­SESSION or WM_END­SESSION message, then it goes into the Blocked Shutdown Resolver screen. That much is obvious. What is perhaps less obvious is that every other window that hasn’t yet replied to the message also goes into that screen, even if they aren’t the ones that are blocking shutdown.

The system sends the shutdown messages to each window in turn. If a window blocks the message, then not only does it prevent shutdown (for a time at least), but all the other programs which haven’t yet received the WM_QUERY­END­SESSION message are also prevented from receiving it. As a result, all those other programs also go into the BSDR, not because they are doing anything wrong (yet), but because they are stuck in the queue behind the bad guy and therefore could potentially block shutdown in the future.

I assume the theory here is that it’s better to list everybody who could potentially cause a problem, rather than just listing the one who is causing a problem right now, only to frustrate the user when they resolve that problem, only to have a new window show up on the list. Shutting down the system would turn into a game of Whack-a-Mole.

Programs typically block shutdown if they need extra time to clean up (for example, closing a database or disconnecting from a server), or if they need to ask the user what they want to do with unsaved data.

If you click the Shut down anyway button in the Blocked Shutdown Resolver, then the system gives up waiting for responses from WM_QUERY­END­SESSION messages and proceeds with shutdown. The programs that were asking questions will never get the answers, and you may end up with a corrupted database or unsaved data.

If you click Cancel, then the shutdown is canceled and you return to your desktop. You’ll want to click this button if the program is asking you a question that needs to be answered before it will permit shutdown to continue, typically a “Save changes?” dialog.

If you do nothing, then the system will automatically click the Shut down anyway button after a few seconds.

The Blocked Shutdown Resolver was added to address the common problem where you go to the Start menu, click “Shut down”, and then walk away from the computer or close the lid to your laptop. But then you come back to your computer some time later, and the shutdown got stuck because some application got stuck cleaning up or simply rejected the shutdown request, so your computer never shut down at all. In the case of a laptop, this exhausts the battery, which is really frustrating because you’ll pull out your laptop some time later so you can start doing some work and discover that the battery is dead.

One phenomenon you may observe in the Blocked Shutdown Resolver is that of programs gradually disappearing from the list. This is the flip side of the “If one program blocks shutdown, then all programs block shutdown” principle. As each program receives and responds to the WM_QUERY­END­SESSION message, it disappears from the list.

Just because a program is on the list doesn’t mean it’s being bad. It may be on the list because it is still waiting its turn.

 

Author

Raymond has been involved in the evolution of Windows for more than 30 years. In 2003, he began a Web site known as The Old New Thing which has grown in popularity far beyond his wildest imagination, a development which still gives him the heebie-jeebies. The Web site spawned a book, coincidentally also titled The Old New Thing (Addison Wesley 2007). He occasionally appears on the Windows Dev Docs Twitter account to tell stories which convey no useful information.

21 comments

Discussion is closed. Login to edit/delete existing comments.

Sort by :
  • GL

    > If you do nothing, then the system will automatically click the Shut down anyway button after a few seconds.

    As mentioned by many this seems to be not the case.

    One question that could be figured out by experiments, but I'll ask anyway: Do apps receive , or is that postponed until Shutdown anyway or Cancel is chosen or all apps approve shutdown?

    > As each program receives and responds to the message, it disappears from the list.

    Case 1: An app approving shutdown is sent immediately. It wouldn't make sense for to have being .

    Case 2: An app...

    Read more
  • ‪ ‪

    “If you do nothing, then the system will automatically click the Shut down anyway button after a few seconds.”
    Realy? What is AutoEndTasks registry?

  • Jernej Simončič

    I really dislike that the BSDR notification is now full-screen always-on-top – on XP you could navigate to the blocking program and resolve the problem, which would let the shutdown continue normally, nowadays this isn’t possible any more.

  • Georg Rottensteiner

    One of the problems with the BSDR is, once it appears and is canceled, all the already properly marked as restarting programs are removed from the restart manager list.

    Say you have Visual Studios and a text editor open, and one other program, that blocks via MessageBox or similar. Once Visual Studio has properly shut down the blocking program triggers the BSDR. Choose cancel, and answer the blocking question. Now triggering shut down again, the Visual Studio restart info is gone and it won't restart with the closed solutions on the next startup.

    One of the reasons why I'm adding a system...

    Read more