Thoughtful, detailed coverage of the Mac, iPhone, and iPad, plus the TidBITS Content Network for Apple consultants.

Lion Zombie Document Mystery Solved

Although I’m the author of “Take Control of Using Lion,” I don’t actually like Mac OS X 10.7 Lion very much; the book doesn’t express my biases explicitly, but you can sense them clearly enough if you read attentively. And one of the Lion features I dislike the most is Resume, which I privately think of as “Zombies.” Resume comes in two parts:

  • When you start up the computer, Lion wants to launch all the applications that were running just before you previously shut it down. The same applies, obviously, to restarting, or logging out and logging back in.

  • When you launch an application, Lion wants to open all the same documents and windows that were open in that application when you previously terminated it.

I don’t like these behaviors because, to me, they fly directly in the face of precisely what restarting the computer or quitting an application is for. I like to quit an application exactly as a way of making that application close all its windows and forget about all its open documents. I like to restart the computer (very frequently) as a way of blowing out all the cobwebs, clearing memory, and putting the computer into a fresh state, with no applications running. I don’t want applications launching themselves automatically (aside from the few utilities that I’ve designated as Login Items in the Users & Groups preference pane), and I certainly don’t want applications that are launched to reopen a bunch of stale windows and documents from the past.

In my book, I also explain how to take control of these features — which in my case means turning them off. When I restart the computer or launch an application, I want a clean slate, every time. Here’s how I get it:

  • To prevent applications from relaunching at system startup time, you have to take preventative measures at shutdown time: in the dialog that appears when you shut down or restart or log out, uncheck the checkbox that says “Reopen windows when logging back in.” Of course, this means you have to avoid situations where that dialog doesn’t appear — especially because, until the recently released 10.7.4 update, Lion would check that checkbox by default even if you had previously unchecked it. But, thanks to that update, the checkbox is now staying unchecked; I suppose I should be grateful to Apple for small favors.

  • To prevent windows from bringing their documents and windows back from the dead at launch time, uncheck “Restore windows when quitting and re-opening apps” in the General preference pane. (That hyphen is Apple’s mistake, not mine: Apple really does write “reopen” in one place and “re-opening” in another.) It’s possible, instead, to use a third-party utility such as TinkerTool to turn off this behavior for individual applications, as I explained in “Lion Frustrations? Don’t Forget TinkerTool” (29 October 2011), but I prefer to turn off this feature globally.

However, there’s a mystery. Even though I’ve unchecked “Restore windows when quitting and re-opening apps”, some applications still sometimes bring their zombie windows back from the dead when I launch them. Until recently, I hadn’t paid much attention to this mystery; I tended to shrug it off as more of Lion’s inscrutable annoyance. After all, coming back from the dead is what zombies do, so it didn’t surprise me that a few of them wouldn’t stay dead. I just sighed and closed the spontaneous windows by hand.

At the same time, though, it irked me that, while I was supposed to be telling readers how to take control of Lion, I still couldn’t seem to get full control of Lion myself. I mean, Lion has been around for a year, and I still don’t have these issues straightened out? Shameful.

A few days ago, though, I suddenly thought I’d detected a pattern. I made a few tests, and sure enough, there it was: the mystery was solved.

I know you’re right on the edge of your seat, so I won’t keep you in suspense. Here’s the answer: If an application is running at the time you shut down the computer (or restart or log out), that application will reopen its zombie windows the next time it is launched, even if you have told it not to.

As soon as I’d noticed this pattern, I also understood the reason behind it. In Lion, there’s more than one way of quitting an application. When you quit an application (by choosing Quit [ApplicationName] from the [ApplicationName] menu, or pressing Command-Q), the application shuts down in good order, and your preferences with regard to zombie windows are enforced. But when Lion quits an application (because you’ve told the computer to restart or shut down while the application is running), it takes a completely different approach. It reasons that we need to get the heck out of here as quickly as possible, so it uses a new-in-Lion protocol called Sudden Termination (if the application in question supports it).

The purpose of Sudden Termination is to support Resume (wouldn’t you know it?); most applications (perhaps all) that support Resume also support Sudden Termination, and it’s here that the trouble lies.

The idea is that, as in iOS, a Sudden Termination–enabled application constantly saves its state, including what windows are currently open. That way, the application can be terminated quickly, because it has no work to do at termination time; all the work has already been done. Under Sudden Termination, the application is never even told that it is being terminated! (In technical terms, it is never sent a Quit event.) Instead, the system simply pulls the plug; in effect, it simply and summarily clears the application from memory and rips it off the screen.

Do you see where this is going? Because the application is instantly blown away, it never has a chance to perform any tasks associated with quitting. In particular, it never has a chance to obey your dictates with regard to Resume! The application has been saving state all along, and now, when the application is sudden-terminated by Lion’s restart or shutdown process, that state is simply left in place — where the system finds it the next time the application is launched, resulting in zombie windows coming back from the dead.

Naturally, I regard this as a bug. But it isn’t a bug I expect Apple to fix any time soon (or ever), because it’s rooted in the new Lion philosophy of making the desktop more like an iOS device. Reading the developer documentation, you can actually witness Apple persuading programmers that Sudden Termination is a good thing, “designed to improve the user experience.” (You also discover that it is of a piece with Automatic Termination, which I complained about in “Lion Is a Quitter,” 5 August 2011.) Fortunately, until Apple fixes this problem (which will presumably be never), there’s an easy, though tedious workaround. Before I restart or shut down my computer, I quit every application. Slowly. Deliberately. Manually. Myself. One. By. One.


PDFpen and PDFpenPro 9 add 100+ enhancements to improve your PDF
editing experience, with annotations, Tables of Contents, and more
export options. For PDF reviewing, editing, signing, redacting and
exporting, PDFpen has you covered. <>

Comments about Lion Zombie Document Mystery Solved
(Comments are closed.)

Redwing  2012-05-23 14:16
There's an application called HimmelBar that will 'quit all' for you properly from the menu bar. It has been around for years now, but seems to be Lion compatible. It was free when I installed it.
Adam Bell  2012-05-23 16:31
Agree completely, Matt. Unfortunately too, if you invoke an AppleScript to find and quit running apps, the app takes the fast way out without closing the state. HimmelBar does work on all the apps I usually have open except for Safari, for some reason.
Safari seems to have a mind of its own. It frequently pops open windows I thought I had closed. It's unbelievably annoying to click on a link and have to wait for Safari to load multiple windows and tabs.

I'm getting really close to dumping Safari completely. Sadly my streamlined browser of choice, Camino, seems destined to live only in the history books.
Adam Engst  An apple icon for a TidBITS Staffer 2012-05-24 08:37
I generally like browsers to bring tabs back, unlike documents, but I can see how others might not.

Camino is still under development, though not changing much. Personally, I'm using and liking Chrome the most these days.
Norbert E Fuchs  An apple icon for a TidBITS Benefactor 2012-05-24 03:24
Matt, I agree with you that Mac OS X should not know better than you. However, there are situations where you may want to continue exactly in the situation in which you quit.

Here is one example: I use TextWrangler to edit a set of interrelated Prolog modules, and I am glad that TextWrangler offers the convenient option to open the complete set after restart.

Matt Neuburg  An apple icon for a TidBITS Staffer 2012-05-24 08:27
Ah. But if I want to retain the memory of this particular set of windows as I quit TextWrangler, all I have to do is press Option-Command-Q when I quit it; the Option reverses the global Resume setting. So Resume is behaving exactly as I want now (i.e. it's off by default, and I can turn it on for exceptional situations such as the one you describe), *except* for the Sudden Termination behavior described in this article, which I regard as a bug.
Norbert E Fuchs  An apple icon for a TidBITS Benefactor 2012-05-25 04:50
Maybe, I wasn't quite clear in my message.

The option that I mentioned is an option of TextWrangler itself, not related to the global Resume setting.
Adam Engst  An apple icon for a TidBITS Staffer 2012-05-25 06:10
Indeed - BBEdit and TextWrangler are both good about putting you back where you were before quitting, on their own without any connection to Lion's Resume feature.
Matt Neuburg  An apple icon for a TidBITS Staffer 2012-05-25 09:04
Ah, yes, I see now. Lion features such as Resume and AutoSave are implemented at system level, and applications that subscribe to them inherit their flaws and annoyances. BBEdit demonstrates that similar features can be implemented independently by the application itself, and can work in a nicer way. Maybe it would have been better if Apple had encouraged developers to implement such features independently from the bottom up, rather than trying to impose them universally from the top down.
Arne Glassbourg  2012-06-04 17:27
"Before I restart or shut down my computer, I quit every application. Slowly. Deliberately. Manually. Myself. One. By. One."

What a drag! Sounds like Windows 98 or earlier. :-(
Jeff Hecht  2012-06-04 17:41
What worries me about bringing documents back from the dead is when the zombies really are dangerous. I have hit malware sites where I want out fast, and have had to shut down everything; I don't want them coming back. And I have hit sites that repeatedly froze the browser every time they rebooted. Those are scary zombies, and when you hit one of them, you don't have the luxury of quitting applications one by one.
Matt Neuburg  An apple icon for a TidBITS Staffer 2012-06-04 22:12
Good point. In the early Lion days I did an installation with the Installer application, which caused a restart, which brought the Installer back from the dead even though the installation was over. And I've gone to a download page in Safari, had the download happen, and restarted, only to have Safari reappear and the download happen again.
Howard  2012-06-04 18:56
I haven't tried cmdQuit, but it's supposed to take care of quitting everything precisely in order to get around the Resume setup. This is where I found it—
I don't see it as a bug, but as a feature. 1. If I were to crash, I would like to know where I was, and be restored to that state. The Sudden Termination feature exists for this situation. 2. If Lion does terminate through auto termination, I also want it to restore state. So, my typical practice is that before I shut down or restart, I simply quit all apps I don't want to restart.

Unlike you, however, I decided to try to force myself to like the auto-resume feature. It was irritating at first, but I quickly learned that if I didn't want something to reopen, I ought to close it before quitting. End of problem. Now, I find that I really appreciate not having to find documents I work on over long periods, even if somewhat sporadically.

Trade-offs--yes, benefits--many. I don't expect everybody to be like me, but in this case, the reason is to save you in the case of a crash. A trade-off I think most would consider positive on balance.

¿¿¿¿¿ ¿¿¿¿¿  2012-06-05 02:31
On the subject of Apple typos, see if you can spot the misspelling of Thunderbolt on this page in the Japan Store:
Apple used to provide a link for readers to point out errors on pages, but appears to do so no longer.
Robert Morgan  2012-06-05 11:45
This is one of the annoyances in Lion that has kept me from upgrading from Snow Leopard. I will ultimately move to Mountain Lion though and expect the shut down behavior to be the same. This article and the discussion will be extremely helpful in smoothing the transition.