How To Shutdown a Computer

Sometimes I still feel like we’re in 1982 when it comes to really basic things like turning off a computer. Why do we have to select shutdown from a menu? Why do we have to carefully save each open file? Why don’t programs stop when we tell them to? (Time Machine has now been spinning for hours, and won’t stop even though I’ve told it to.) Why is this so much more complex than it needs to be?

In the future, here’s how shutdown should work:

  1. You flip the power switch.

That’s it. No shutdown menu item. No wait for the system to hibernate. No opportunity for applications to save data. Nothing.

Then, when you turn the power switch back on, the entire system is restored with all data, windows, and programs intact (optionally after typing in the usual username/password credentials.)

In 2009 there is no excuse for an application to lose data because it hasn’t been recently and explicitly told to save. Nor is there any excuse for an application to block the system from shutting down. When I turn my computer off, it should go off, and when I tell an application to quit it should quit. More to the point, the operating system should forcibly terminate that application. I am thoroughly sick of applications that think File/Quit (File/Exit for Windows users) is a suggestion. It’s not. It’s a command, and one they should immediately respond to.

Few applications today get this right: not on the Mac, not on Windows, not on the Web. (Web apps such as WordPress do actually get a little closer to this, but many still launch popups telling you you may lose data if you close a window. There should be no such popups because they shouldn’t lose data, ever.) Firefox helpfully offers to restore all the open windows when the applications is relaunched, including after a force quit. More applications should do this. However even Firefox occasionally gets wedged and refuses to quit when told to.

There are actually a few steps to reaching this simplified nirvana, so maybe I’m asking for more than one thing here. Most laptops and applications can handle a system going to sleep. We just need to make sleeping a little faster (or at least less intrusive to the user) and possibly hook that up to the power switch in the hardware.

However, when waking from sleep, the operating system restores each application to the state it was in previously. We also need to make sure that applications are ready to be terminated with extreme prejudice in circumstances where the operating system will not restore their stack and heap. In such circumstances a character or two of data loss may be acceptable, but no more. Applications should save constantly to persistent storage without waiting for the user to tell them to do so. Furthermore, when writing complicated data structures they should maintain integrity even when they’re interrupted in media res. The techniques to do this are not complicated are hard to understand. They have been implemented by server software like Oracle for years now. We just need to demand the same sort of reliability from our desktop software.

A little more bleeding edge (but only because no one has bothered to do this yet) applications should maintain data integrity even in the face of flaky and unreliable hardware. Filesystems should not be tied to any particular physical drive. (No, RAID helps but doesn’t quite achieve this. RAID controller failures still cause data loss.) Better operating system support and more abstract filesystems that aren’t tied to particular disks would help here. However in the absence of this, applications could still store their data across multiple file systems, and they should do this without asking the user where to save or how to configure the disks. (Whether a traditional hierarchical file system is still the right metaphor for storage is a subject for another article.)

We take too many things for granted merely because that’s the way they’ve always been. But what made sense in an era of 64K floppy disks that could write a hundred bytes a second no longer makes sense in an era of terabyte hard drives that write a hundred megabytes a second. It is time to make saving files as obsolete as remembering to fill your fountain pen.

48 Responses to “How To Shutdown a Computer”

  1. David Mitchell Says:

    One of the things I loved about the PalmPilot was immediate on/off and most applications didn’t need saving or quitting.

  2. Elliotte Rusty Harold Says:

    Mobile devices may indeed be the wedge that brings this style of no-save interface into the mainstream. No backwards compatibility issues, and no expectation that they will work like a traditional desktop computer. As they get more powerful they will replace first laptops and then perhaps desktops: just plug into a monitor, a keyboard, and a power supply. After all, no one really cares how big the box is. We want big monitors and full size keyboards but the box that holds the CPU only needs to be large enough to plug all the peripherals into.

  3. Patrick Mueller Says:

    Keep in mind, the PalmPilot was almost ALWAYS “off”. Even if the display was on, the CPU was typically asleep. It ran long enough to process an event (maybe a touch screen event), and then went “off” (asleep, more like it). So the model there is a little different. But I hear ya, I want the “effect” that it provided.

  4. Peter Cooper Says:

    It depends on your definition of “shutdown”. If I shut the lid of a MacBook Pro, it’s “off” by most pragmatic measures and I know when I open it again, it’ll be back on with everything intact. This assumes you not planning to leave it in this mode for several days, of course ;-)

    My Mac Pro is not quite as slick, but it sleeps pretty fast. I think the technology is all there, but the UI is not. Ideally I could push the power button on my Mac Pro, and it’d sleep and hibernate simultaneously.

    I don’t see the value in supporting a complete loss of power, as with turning the power switch off, as outages are few (in most places) and power switches often hard to access or not switchable anyway (especially in the US). That said, I expect this support will come when high speed memristor memory comes along, or another form of non-power dependent ultra fast memory (so that state can constantly be stored and maintained).

  5. mxtbcca Says:

    > only needs to be large enough to plug all the peripherals into

    Maybe not if you use some form of wireless tech for the peripherals:

    * wifi for the keyboard, mouse and printer

    * laser for the monitor

  6. ed Says:

    On OS X, apps can disable sleeping, and I doubt that Windows is all that different. Apps can also decline the OS callback that tells them to prepare for sleep. Device drivers can also get into this “now I lay me down to sleep” ritual, so there’s still a certain amount of cooperation that goes on here.

  7. Mr. Boso Says:

    Joel Spolsky beat you to the punch: http://www.joelonsoftware.com/items/2006/11/21.html

    This is one of those relatively rare instances where I think the Vista UI actually comes out ahead on the Mac. The big glowing button puts the computer to sleep relatively quickly. Not fast enough, but a huge step up. And yes, it should be the power switch.

    Some applications actually do handle persistence correctly. That is, they automatically save every user action and only prompt if you want to save copies. We tend not to think about them though. Here’s are some that come to mind:

    Quicken
    Quickbooks
    iCal
    AddressBook
    Stickies

    I think a more interesting post might be design guidelines on how to develop such applications. For example, certain applications have very valid reasons for keeping things open that take a while to close correctly. But those applications should still quit quickly. Perhaps there are paradigms for shutting down resources in a separate invisible process? Of course, such a process would need to play very nicely with sleep and the power switch.

  8. James A Says:

    You’re not taking it far enough. With proper design, we should be able to avoid ever pressing the on or off button.

  9. Brandon Says:

    Along the same lines of you talking about quitting an application: I have always wondered this myself. Why is it that when I say End Task on a program it doesn’t always end right away? It should be the operating systems job to end that dam task. Stop drawing it’s window, kill it’s memory and stop giving it CPU cycles. Bang I don’t give one shit what the application is doing or needs to do. When I say end task, you end it immediately simple as that. Same with file deletion. If I tell the operating system I want to delete a file, and it comes back telling me I can’t because it’s in use, you give me the option to delete anyway! It is my choice and my responsibility that whatever application is using that file will crash. I don’t care, I am the computer operater, not the software. If I want that file gone, there is never a good reason that you cannot remove that file. The operating system should ALWAYS have the power to override ANY application no matter what the circumstances.

  10. Manish Says:

    Totally agree. My blog app saves everything without prompting unless specifically told to discard, has autorecover and backs up the database regularly.

  11. Greg Says:

    They already though of that.

    In XP:
    Right click desktop – Properties – Screen Saver tab – Power – Advanced tab
    “When I press the power button on my computer” – Select Stand by

    Press the button, it turns off, press it again, all your work is restored.

  12. 4chan Says:

    However even Firefox occasionally gets wedged and refuses to quit when told to.

    Try Opera.

  13. Kamil Kisiel Says:

    One potential flaw with not allowing apps to prevent a machine from going to sleep.

    Say you have a computer set to automatically sleep after 15 minutes (as I do mine, in case I forget to turn it off when I leave). Now say you start listening to music on the computer. If the music player app is not allowed to keep the computer from going to sleep, it will sleep in the middle of playing music. Therefore you need to allow applications from keeping the system from sleeping. Of course, some other application writers will either intentionally or unintentionally also use the same API to keep the computer from sleeping. Now you’re back to the point where you can’t ensure automatic termination.

    How do you solve that problem?

  14. John Cowan Says:

    ERH: A terminal application, especially one that’s sshed to another box (possibly by way of a bastion), would require really impressive state restoration to handle instant-off/instant-on, especially the latter. It’s easy to tear down stateful connections, not so easy to put Humpty-Dumpty together again.

    Peter Cooper: If you are still consuming power when you are not doing anything, you are wasting it. On battery, this is bad for you; on AC power, it’s bad for everyone.

    Brandon: End Task works like that primarily because Windows apps were born in a cooperative environment where the bad behavior of one app affected all apps, and apps had to be given a chance to clean up or the entire system would be wedged. This is less true than it used to be, but old bad designs persist. On Linux, when you terminate an application with extreme prejudice, it really is gone. Likewise, the Linux file system allows files to be deleted while in use, and the using application still sees the file but nobody else can. (I assume OS X is like Linux in these respects, but I don’t actually know.)

  15. Elliotte Rusty Harold Says:

    Kamil, an automatic shutdown due to a period of inactivity can be treated very differently from a deliberate shutdown initiated by the user. An active application could (and should) block a computer from going to sleep due to inactivity. It should not block a user-initiated shutdown.

    John, let’s face it: only mega-geeks use stateful terminal applications. Probably less than 1% of Mac users have ever opened Terminal and fewer have used Terminal to actually connect to another system.

  16. Canadian Business Blog » Blog Archive » How do you turn this thing off? Says:

    [...] good to know I’m not alone. I stumbled across an interesting blog post by some fellow named Elliotte Rusty Harold who is, according to his blog, an adjunct professor of [...]

  17. Joe Says:

    It’s true applications sometimes prevent sleep, but if we start pushing this model, then more and more software companies will start to deal with it rather than inconveniencing their users. Obviously these things can’t change all at once; you just have to make the change and wait for (and encourage (and nag)) adaptation.

  18. Michael Says:

    This, is stupid and ignorant. You have that option already, although most people wouldnt recommend it on a regular basis. 2009 no excuses BLAH BLAH BLAH. Shut up and take it.

  19. Ron Says:

    Some of what you intend to accomplish can be done by using your pc as a network client. Files get saved locally into a version control and are synced often to an upstream system. Power off whenever you like because your data is stored elsewhere. A good example is a client machine dedicated to running a Thunderbird like app for remote access to email via IMAP.

  20. st Says:

    We can’t always live in a smalltalk world, can’t we?

  21. Jacques Chester Says:

    There was a commercial OS that had this — orthogonal persistence. KeyKOS I think it was called. It fed into EROS-OS which is the ancestor of the Coyotos project.

    Usual problem though: who’s going to port all the old code? You?

  22. Timmy Jose Says:

    Nice, simple rant. I agree with all the points that you have raised here Elliotte. It almost seems ironical that an ’80s (and earlier) mechanism like the LISP “image” could do pretty much the same in software which full-blown Operating Systems can barely dream of today. Perhaps the average tech-IQ of the consumer has yet not increased enough to force hardware and OS manufacturing companies to give this a real thought. Though I’d say you’re better off than me wallowing in Windows land ;-)…

  23. Daniel Says:

    Brandon: you’re looking for “End Process”, from the Processes tab. The End Task button was probably made just so people could end frozen apps, and is more comparable to a SIGTERM; giving it full kill powers could have catastrophic results, so they hid that in a context menu in a more intimidating tab.

    If I recall Raymond Chen correctly, somewhere along the latest versions of Windows applications lost the ability to cancel a sleep action. Two seconds after the user request, the system just forcibly enters sleep mode. Though I’m under the impression that even if I’m recalling correctly, I must be forgetting something important.

  24. Jesse McNelis Says:

    “That’s it. No shutdown menu item. No wait for the system to hibernate. No opportunity for applications to save data. Nothing.”
    There are various technical reason why this isn’t currently the case.
    1. How often should a program save it’s data to the harddisk? the more often it does this the more times the harddisk needs to be spun up which uses more power and reduces the life of the disk. A longer period of time between saving means the instantly off computer will lose an amount of data.
    2. RAM is still volatile, with out power it will lose your data. This makes ‘sleep’ without first saving to disk a risky option.

    “applications should maintain data integrity even in the face of flaky and unreliable hardware.”
    code runs on hardware, thus the code can’t do anything to detect failure of the hardware..because in reality that is the hardware detecting it’s own failure..but if it’s faulty you can’t trust it to make those assertions. You could recover from memory errors if you saved everything three times on different parts of memory and than compare them on access, but then everything would require three times more memory and be really slow…it this won’t protect you from CPU or memory controller issues anyway.
    Hardware failure is rare enough that this isn’t a big problem and isn’t worth the huge investment.

    “More to the point, the operating system should forcibly terminate that application.”
    The operating system does forcibly terminate applications, but it also tries to do this in a way that doesn’t lose data or corrupt other things. You want to forcibly quit firefox and don’t really care about it losing data, sure. But you probably want the operating system to do all it can to recover the data in your frozen accounting software. The operating system doesn’t know how important this data is to you, so it treats everything as ‘very important’.

    The people who makes these systems are very smart people, and if it was possible for things to be the way you want them, they’d find a way to do it. But right now with our current hardware this isn’t really possible.

  25. Matt Thompson Says:

    Umm… everything you just asked for existed in the Xerox Star systems. Physical shutdown caused the execution stack to unwind, save itself, and push the user’s desktop state across the network to a peer system (whichever was available) or to a known server.

    BTW – the software for these systems was ported to SunOS and continued to run for another 10 years (in the 90′s).

  26. Baz Says:

    On my windows box, I have a shortcut called KILL ME NOW which executes: shutdown -s -t 0 -f

    Yes, I know its unsafe. But sometimes I can’t hang around to see which of excel/outlook etc are going to refuse to shut down because I havent confirmed something I always confirm anyway (aaagh). This is what irks: I can understand shutdown being slow, but programs that cannot be configured to shutdown unattended (by autosaving, etc) are braindead.

  27. Assurance of Confidence, Easy to Maintain Says:

    On shutting down a computer…

    Elliotte Rusty Harold writer:

    Sometimes I still feel like we’re in 1982 when it comes to really basic things like……

  28. Michael Alan Miller » The ox cart and the SR-71 Says:

    [...] | Posted by Chill on 18 Jan 2009 at 01:22 am | Agreed. [...]

  29. Mark Thornton Says:

    While Vista does enter (hybrid) sleep quite quickly (and once started there is no cancel), I have a growing catalog of state which is not restored reliably. The timing of reestablishing external devices is fragile — e.g. monitors that don’t come back on because the graphics card decides they aren’t there any more, USB hard disks that don’t wake up as quickly as the OS requires, and network connections are unsurprisingly broken.

    Java doesn’t provide applications with notification of sleep or wakeup. Even the notification of shutdown doesn’t work properly on Windows.

    In short, there remains much to be done for this functionality to work as it should.

  30. James Orenchak Says:

    Elliotte wrote “only mega-geeks use stateful terminal applications.” Elliotte, you’ve just turned thousands of sys admins across the world into “mega-geeks”, as well as thousands of technical savy business folks who work for banks, insurance companies and other large organizations or engineers who need to access systems in electric power plants or oil refineries and who have to access legacy applications via a “golden host” due to IT security requirements.

    It is indeed strange that the type of functions you’re requesting were, at least partially, available decades ago in smalltalk . Why has smalltalk been perishing in the market, although smalltalk offered functions that the market leaders haven’t yet implemented, years later?

  31. Jonathan Peterson Says:

    Funny to see comments that boil down to :
    A) It’s impossible with current hardware limitations
    B) It’s easy just do “X”
    C) Legacy platform “Y” did this 20 years ago

    The power switch on a computer should function at least as simply as it does for a car. There are no moving parts and nothing that will blow up if it is shutdown incorrectly. Users don’t care whether the PC hibernates, suspends, sleeps, saves browser session state, parks drive heads, runs fans until the CPU cools or anything else.

    The user is telling the computer that they are done for now – it’s up to a competent operating system and hardware platform to deal with the details and put itself into the lowest possible power mode as a result. And there is NO excuse for requiring application developers to touch their code to make that happen – the OS KNOWS the current state of all of it’s various Von Neuman machines – it just needs to store them and restart them.

  32. Elliotte Rusty Harold Says:

    James,

    Yes. Sysadmins qualify as mega-geeks. :-)

    As to legacy systems, well, yes, they’re legacy for a reason and they’re rapidly being replaced by sessionless designs sitting on top of HTTP.

  33. Mark Thornton Says:

    @Jonathan Peterson
    The OS can’t restore the state of network connections that use a stream protocol, so the hibernation/sleep/shutdown will be visible to applications using such connections. Some of them don’t recover gracefully.

  34. Klaus Says:

    Yeah, I really liked the “Mac power button approach” from the middle 90ies or so. There you had it.

    A simple button on the keyboard. You would press it to power up the computer; you would press it to shut it down.

    Yeah; and then us stupid students crawling on the ground looking for the plug for our computer.
    Because far to often, the Gofer interpreter (some sort of haskell functional language thingy) kept crushing the whole
    computer. Of course, the keyboard power button wouldnt work any more.

    Only chance to continue – get on your knees and unplug.

  35. Tsu Dho Nihm Says:

    I have a different view here. I don’t want programs to save anything automatically. I only want them to save data when I tell them to. And I don’t want this going into some strange pending save state that preferences and the like go into. For example, on Windows (just about any version ever) try changing a simple setting, like the font used on icons, and save. Now pull the plug. Plug it back in, power up, log in, etc. Notice that your setting hasn’t actually changed even though you explicitly told it to @#^$&@ save!

    When I hit the power button, I don’t want to see any messages like “closing applications”, “saving personal data”, etc. I just wan the thing to shut down. Don’t save anything for me because I should have already done that. Just shut the power off.

    Ah, well, that’s my little rant on this topic!

  36. Jochen Bedersdorfer Says:

    I agree wholeheartedly. In the times of Ghz-CPUs and Gigabyte disks there is no reason why a simple office app should not be able to store your stuff for every keystroke and provide unlimited undo. There is no reason why you can’t have an arbitrary number of older versions of a file. There is no reason I should even have a save button.
    The less I have to think about these strange concepts (how would “save” work on a piece of paper!), the better.
    The computer and it’s various intricacies should disappear and make room for a personal digital assistant.

  37. biker dude Says:

    I don’t even have a shutdown button and my computer is on all the time. never the less I like the idea where you just turn the sucker off and then on again and you are in the same place. well I see some apps are doing just that like FF saving tabs and states… so wait a decade or so and we have it in OS.

  38. Thomas Sherer Says:

    I bought OS/2 Warp way back when it was first released. I was editing something using its bundled text editor when the power went out. I was anxious because I had not saved my file yet and feared I would have to start all over. When the power came back on, so did my computer. There was no long boot sequence or other nonsense, and the screen appeared almost exactly as it was when the power failed, text editor, document and all, maybe I lost one or two characters. I took this as a sign that the PC had finally come of age, as that was just the sort of behavior which I had become accustomed to having been a mainframe user for almost 20 years. Its a really simple trick for an operating system which uses virtual memory. The reason we don’t have this feature in all computers today might be because amateurs have been designing our operating systems. This goes for Windows, OS/X and Linux. Linux being the only one with any excuse for this at all!

  39. Lazy bastard Says:

    In my future, here’s how shutdown should work:You just say shutdown aloud.That’s it.

  40. simplemind Says:

    the simplest thing is to not put the computer/labtop on at all.
    this avoids any problem with switching it off.
    even more …

  41. dog Says:

    We had this back in the 80s. On my apple ][c I would just turn the machine off and it was off.
    I don’t see what the big deal is.. all these filesystem caches should be more aggressive in writing back the data to disk on idle.. Sure.. make me wait a few 100 ms, but other than that it should be instantaneous.

    I don’t care so much about restoring that is what sleep/hibernate are for (though they too could be faster). Why is a cold boot bad? It wasn’t so in the days of ProDOS.

  42. Steve Walker Says:

    Psion managed this as early as the early 1991 with the Series 3, followed by 3a, 3C, 5, 7 and Netbook. It was something that I always appreciated – you never had to remember to save anything because it worked on flash memory (or some such geek speak) and you could just turn it off. Some elements of this remain in Symbian phones today, which is nice when you find it. It’s ridiculous IMHO that PCs and Macs, more than a quarter century after their birth, remain so fragile when it comes to the likelihood of losing data in a system crash.

  43. eleg Says:

    Have a look at:

    http://en.wikipedia.org/wiki/Prevayler

    http://www.prevayler.org/

  44. Tom Anderson Says:

    Mark Thornton Says:
    January 18th, 2009 at 4:47 am “While Vista does enter (hybrid) sleep quite quickly (and once started there is no cancel), I have a growing catalog of state which is not restored reliably. The timing of reestablishing external devices is fragile — e.g. monitors that don’t come back on because the graphics card decides they aren’t there any more…”

    No, it’s not perfect, but Vista’s sleep is much much better than XP’s. Yes my monitors don’t always come on, and explorer.exe crashes from time to time, but actually I have about a 98% success rate with sleep. This is definitely a direction for continued work, IMO. As it is, I always use sleep with my notebook computer. It is really great–close the lid and it’s (usually) sleeping. Throw it in the bag and then I’m off. A couple minutes or hours later, hit the power button and five seconds later everything is back the way it was.

    And once a week or maybe more often, I do turn off my computer all the way…

  45. Bobby Says:

    I never turn my PC off.
    That solves half the problem.

  46. rpggames Says:

    Very interesting, i agree, it’s about time we get rid of the long shutdown process. People got used to things and large business just don’t see why they should give us for free something most don’t request. But we won’t go further if we stick to the old ways of doing things, like saving documents (hard drive space is not limited to a few hundred megabytes anymore) or turning the computer off. Great article, i think some decision makers in OS business should read it!

  47. spndr Says:

    stop ranting about something meaningless, if your so bothered about not shuting down quick enough go buy a pen and paper and shut the fuck up.

  48. Paul Says:

    Well, you can reprogram your power button to hibernate when used. The delay in hibernation is due to cheap hardware and storing the RAM onto the hard drive. If you had a large flash drive,hibernation would be LOTS faster. In the future, files will still have to be closed, otherwise they will get corrupted. It is up to technological progress to hasten these issues up. Programmers are limited by the ability of the hardware.

Leave a Reply