Sometimes I shutdown Ubuntu and …it takes ages to actually power off.

Am I alone?

Am I unreasonable?

I’m not sure, but I am highly caffeinated — massive props to all the wonderful folks who buy me a coffee (it really does get spent on coffee) ☕️ — and I haven’t written anything for about 5 days.

Which is almost as long as my shutdowns seem to take…

Slow Ubuntu Shutdowns Are Real

When I hit shutdown (or run sudo shutdown now from a terminal) I expect Ubuntu to do its “going… going… gone” process in 5-10 seconds, max. I want to hit shutdown, be able to close my laptop’s lid, stuff it in my bag, and go buy bread because I’m half pigeon.

And, to be fair, most of the time Ubuntu does do that.

But sometimes it doesn’t.

Sometimes it hangs.

For ages.

Those loading dots on the shutdown screen just keep… dotting.

And I find it highly irritating!

As any Linux geek would, I can hit esc to see what’s happening behind the scenes and almost always the message glaring back at me reads:

A stop job is running for Snap Daemon (57s / 1min 30)

That’s a timer on the end. Yeah, I don’t just get to enjoy a slow shutdown, I get to “enjoy” watching the counter tick up, one excruciating second at a time, unable to intervene until, at last, the maximum allowed time is reached and—BLINK—my computer finishes shutting down.

Ubuntu gives the Snap Daemon 90 seconds to stop and, if by that time it doesn’t… 💀.

Obviously having to (occasionally) endure wait an extra 1 minute 30 seconds for a shutdown to complete is not a major issue (well, unless you’re a mayfly). But it is considerably longer than a shutdown should take, and indeed long than a shutdown does take on other Linux distributions.

Irked from encountering this issue yet again, I went in search of a “fix”.

Fix Slow Shutdowns Due to Snap Daemon

Disclaimer: I am not a snap doctor. I do not know why the snap daemon often refuses to gracefully stop when asked. I do not know how to fix the underlying cause merely treat the symptom.

A nuclear solution™ is to run sudo apt purge snapd, put on some sunglasses, and head off into a glorious Hollywood sunset.

However, l don’t harbour an ideological allergy to the Snap format, and a number of my favourite command line tools are installed as snaps (honest lol). Plus, y’know, I write about Ubuntu and Snaps are kinda core to the quote Ubuntu experience unquote these days.

But I am done enduring recurrent bouts of WHY IS NOTHING HAPPENING-ness.

That 1 minute 30 seconds I wait for the Snap Daemon to meet its (inevitable) end would be better spent propelling my skinny frame to the nearest artisan bakery, or letting the cat in with DEAR GOD WHAT IS THAT IN YOUR MOUTH, SWEET PRINCESS?!….

So I reduced the snap daemon timeout from 90 seconds to (a still rather patient) 30 seconds – winning myself an entire minute of my life back and probably doing irreparable hard to the snap daemon but yolo.

Want to do it too?

  1. Open a new terminal window
  2. Edit /etc/systemd/system.conf (as root) in your fave editor
  3. Find the line: #DefaultTimeoutStopSec=90s
  4. Remove the # (if present) from the start of the line
  5. Change =90s to your desired value, e.g., =30s
  6. Save your changes
  7. Double check you hit save

Now, next time your system restarts — and I pray the shutdown is swift — the new timeout value will get picked up by the systemd deamon and, all is well. If you don’t want to reboot I think you can run systemctl daemon-reload instead, but I didn’t do that so you’re on own if it makes things go funky.

Anyway, that’s it.

Obviously this guide is not an official workaround that I’m paraphrasing from snap documentation. Heck, there could be a very good reason why the timeout is as long as it is, and a very good reason why we ought to put up with waiting for the blasted thing to die but…

Having wasted many, many minutes to this — enough to listen to Britney Spears’ Toxic 3 times on repeat (the internet’s standard measure of time) — I’m done.