When shutting down a computer and the “X app is preventing the computer from shutting down” prompt appears along with a “Shut Down Anyway” button, why does the computer shut down anyway without pressing said button?

101 views
0

Clearly, the app *isn’t* preventing the shut down or, at the very least, the user’s authority is not needed to “shut down anyway.” What’s happening?

Edit: thanks everyone!

In: 13

Often that app is taking longer to shut down than others but before you can force it it’s able to shut down successfully and move on

The app is simply telling the operating system it isn’t quite done with what it needs to finish before it can close, then it finishes and tells Windows it is done and Windows finishes shutting down.

Computer: “Hey, everyone time to go to sleep.”

App: “I’m still running, I can’t go to sleep yet.”

Computer: “Fine, hey user, this app won’t go to sleep, want me to chloroform him?”

App: “Nevermind, I’m finished what I was doing, I can go to sleep now.”

Computer: “Oh, okay. All good here.”

*everyone goes to sleep*

It could be that a process was in the middle of something, like logging or cleaning up other background processes. A lot of these will lock files so nothing else can interfere with it.

When you restart it’s saying “hey wait a minute. I need to finish up first or you’re going to lose this log.” Not too dissimilar to when video games tell you not to turn off the game when you see the auto-save symbol. You’re likely going to lose that save file.

Thats just one example. It could just be a background program that is having a bad day and failed to close properly. These weird things happen sometimes.

When you shut down a computer, the operating system (OS, be it linux, windows, other) has data in RAM that needs to be written to permanent storage (SSD/HDD), and some services need to be stopped in a specific order to avoid issues. Say service X depends on service Y, which depends on service Z…you want to stop them in X, Y, Z order. The OS tells apps to shut down, saves what it needs to, and waits for apps to shut down before it turns off background services. If an app doesn’t exit after a timeout, you get the “do you want to kill it” message.

When an app is told to shut down, it has it’s own things to do. Stop work in progress, save changes, save logs, whatever, and then exit. Some apps aren’t written well enough to notice the OS told them to stop. Some *do* notice, but have parts of them that don’t accept being interrupted so they try to shut down and get stuck waiting on something else. Network apps (web browsers, P2P file transfers, etc) are historic offenders here, they’d be waiting for a response from whatever site they were talking to and just…sit there.

If the OS just killed the app without asking, it might lose things you wanted to keep. The last 30 minutes of edits in a document, a huge file you were downloading that hasn’t finished yet, an ML model that’s been training for the past 6 hours, whatever that app is working on. Nobody likes those surprises, so your computer asks if you want to shutdown anyway so you know *why* your stuff is missing the next time you bring it up.