Taming the Lion: Changing App and Window Auto-Reopen Behavior

Lion’s default behavior of reopening all apps and windows that were open when you shut down is often very handy. For instance if you have to restart because of a problem, log out temporarily for privacy purposes, or anytime you want to pick up right where you left off after shutting down.

Sometimes, though, I have a dozen apps and dozens of windows open and I don’t want to wait for what seems like hours until everything is reopened when restarting, especially on my older, slower MacBook Air. Here are some solutions, other than manually closing each app before restarting.

There is a procedure built-in to Lion to prevent reopening all your open windows and relaunching all the open apps when it restarts or you log out and back in. It does require a choice every time you shut down, restart or log out. When you do so, you will get a dialog box like this.

Just uncheck the Reopen windows when logging back in checkbox (Handy Shortcut: press Spacebar then Return) When you do relaunch an app manually it will reopen with all the previously open windows including anything you haven’t saved (Untitled documents) even if you have unchecked the Restore windows when quitting and reopening apps checkbox in System Preferences/General. (See box below.)

There is a related control over reopening windows when quitting and reopening applications without shutting down, restarting or logging out and in. It’s the Restore windows when quitting and reopening apps checkbox in System Preferences/General and it behaves a little unexpectedly (in a good and maybe-not-so-good way).

 Good: When it is unchecked, previously open windows will not reopen after quitting and relaunching an app (without shutting down etc.) except if you have an unsaved (Untitled) document open. When you relaunch the app, the unsaved document window and any other windows that were open will be reopened despite the setting in System Preferences/General, so you don’t lose your unsaved document.

Maybe-Not-So-Good: Shutting down and restarting or logging out and back in and with the Reopen windows when logging back in checkbox unchecked overrides the setting in System Preferences/General. All windows will reopen when you relaunch the app the first time. If you had a lot of windows open that you really were through with, this can be annoying.


There is a way, if you are comfortable with Terminal commands, to completely disable reloading windows when logging back in. I prefer to have the flexibility to choose on a case-by-case basis.

Sometimes I don’t want apps to relaunch when restarting or logging out and back in and I don’t want all the previously open windows to reopen either when I relaunch the app (i.e. the maybe-not-so-good behavior in the last paragraph in the box above).

The only way I’ve found to do this is have the Restore windows when quitting and reopening apps checkbox in System Preferences/General unchecked and quit whatever apps in which I don’t want windows to reopen before restarting or logging out. Quitting apps one by one is tedious, and generally I want to quit all apps. There isn’t an option in OS X to quit all apps, but fortunately someone has written a handy script to do just this. It’s described in the box at the end of this post.

After the script is downloaded, set up as a Service and optionally a keyboard shortcut created, running it will quit all apps.

You can run it by selecting it in the Services menu in the Finder and almost every app, or using the keyboard shortcut if you set one up, or a little  less conveniently by double clicking the script itself (or an alias on the desktop or some convenient place).

If there are unsaved items, you will be asked if you want to save them before each app quits. You can then shut down, restart or log out. I do want Mail and my Calendar to relaunch when I restart, so I put them in System Preferences/Users/Login Items.

This script can be handy even when you aren’t restarting or logging out, but just want to close the apps and start over when you have too many open.

Here is a link to the quit all apps script and instructions on installing it. There are a few things that may not be clear in these instructions.

Under “The Easy Way”

In Step 1. It’s obvious how to download the script, but they don’t tell you where to put it (you probably don’t want to just leave it in your downloads folder). Well, it doesn’t matter. There is a Scripts folder in ~/Libray where you could put it, but you could just put it in your home folder or Documents or anywhere else.

Under “Assigning a Keyboard Shortcut” (and setting it up as a Service)

Steps 1 through 3 are to install the script as a Service, so you can run it from the Services menu rather than having to double click on the script itself (or an alias on your desktop). The remainder of the steps are optional for assigning a keyboard shortcut.

When you open automator you have to choose a Type for your document. Choose Service.

In Step 3. After you drag the Launch Application action over you have to set the application to be acted upon to your downloaded script. To do this click on the pull down list, scoll all the way to the bottom and select Other… and navigate to where you saved the script.