Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

10.7: Remove Safari session auto-restore Web Browsers
This hint describes how to not restore your previous browsing session after force-quitting Safari in Lion.

I disabled System Preferences » General » Restore windows... almost immediately after I discovered that Lion wants to automatically restore reopened applications to their previous state. Today while browsing with Safari I encountered one of those 'YOU WIN' sites that had a popup where the popup window lacks any controls except an 'Okay' button. That window held exclusive focus for Safari. Oh, and no red 'Close this window' button at the top-left either. The only intended way past this window was to click the Okay button. Very annoying, and I refuse to trust these sites since you don't really know what JavaScript or other code lurks beneath that Okay button. Note that you can't even view the page source since the popup has exclusive focus for the application.

So I did a force-quit on Safari as I've always done pre-Lion. When I restarted Safari this time though, my earlier session was restored including the popup. And now I'm in an ugly loop. If I crash Safari again, I'll be right back here the next time I start Safari. And I will not click that Okay button. Here's one workaround for this issue.

Kill Safari and then remove the file:

~/Library/Saved Application State/com.apple.Safari.savedState

After I did this, Safari restarted 'normally' just opening my default page. I used a Terminal window to remove that file, but you could use the Finder if you know how to access ~/Library in the Lion Finder. Search for the previous hints about this.

The truly cautious among us will want to rename that file rather than deleting it.

If anyone knows of a startup key/mouse combination to avoid restoring from the savedState file for a previously crashed application, I'd appreciate hearing how to do that. I searched and did not find anything.

[crarko adds: Good to know this. If there are key combos to launch Safari in Safe Mode please put your discoveries in the comments.]
    •    
  • Currently 3.13 / 5
  You rated: 1 / 5 (8 votes cast)
 
[32,910 views]  

10.7: Remove Safari session auto-restore | 16 comments | Create New Account
Click here to return to the '10.7: Remove Safari session auto-restore' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
10.7: Remove Safari session auto-restore
Authored by: arcticmac on Aug 03, '11 08:09:34AM

10.6 does the thing where if you crash an app multiple successive times (I think 2?) and use the "relaunch" button in between, it clears out your preferences file so that it'll have a better chance of working on the last go. I don't suppose 10.7 does something similar but with the saved states?



[ Reply to This | # ]
10.7: Remove Safari session auto-restore
Authored by: systemsboy on Aug 03, '11 09:07:39AM

Holding the SHIFT key while launching Safari will also prevent the previous sessions windows from loading.

-systemsboy



[ Reply to This | # ]
10.7: Remove Safari session auto-restore
Authored by: sabi on Aug 03, '11 09:37:53AM

You can hold down Shift while launching any app in Lion and it'll skip restoring your session—this not Safari-specific. Of course, if you don't have to force quit the app, you can use Option-Quit so your session isn't saved at quit.

Same as Shift for safe boot, or to stop login items from running in earlier Mac OS X versions. (Or to disable extensions in classic Mac OS :-).



[ Reply to This | # ]
10.7: Remove Safari session auto-restore
Authored by: Frederico on Aug 03, '11 10:06:04AM

I was sure this was already documented somewhere, but all you have to do is hold the 'Shift' key down when launching (I believe) any application under OS X Lion to prevent saved window states from reopening; this is pretty much the old style 'Safe Boot' / 'Safe Login' command and makes perfect sense.

I have tested this with Safari and TextEdit and it is true for at least these apps; it may not be reliable for applications not fully updated for the Resume feature in Lion.

Please note that if you use Spotlight, Launchbar, Keyboard Maestro, et al, to launch your apps via shortcuts, you may not get the 'Shift' key signal to the launcher agent in time; I find that it is necessary to hold the Shift key while clicking on the icon in Dock or Finder to register the request to launch clean.



[ Reply to This | # ]
10.7: Remove Safari session auto-restore
Authored by: DCJ001 on Aug 03, '11 01:38:28PM

com.apple.Safari.savedState is a folder that contains four files, not an individual file, as stated in the original OS X Lion hint.



[ Reply to This | # ]
10.7: Remove Safari session auto-restore
Authored by: DCJ001 on Aug 03, '11 01:43:18PM

Also, the folder com.apple.Safari.savedState disappears when Safari is quit, and reappears when Safari is opened.



[ Reply to This | # ]
10.7: Remove Safari session auto-restore
Authored by: teegery on Aug 03, '11 03:25:01PM

It should also be noted that if you wish to never have Safari (or other applications for that matter) auto-resume again, if you navigate to the application saved state folder as mentioned above, you can "lock" the folder via the get info window (command+I) and it will open fresh each time.



[ Reply to This | # ]
10.7: Remove Safari session auto-restore
Authored by: macfan001 on Aug 03, '11 04:47:23PM

If you are able to use the command-q option without resorting to force-quit, you can hold down the option key when selecting quit from the menu and 'Quit Safari' changes to 'Quit and Discard Windows' - with the keyboard shortcut being command-option-q



[ Reply to This | # ]
10.7: Remove Safari session auto-restore
Authored by: munas on Aug 03, '11 05:11:39PM

whats about quitting Safari, or other apps you do not want to current stae to be restored, either by holding Alt and use menu or simply Alt+Cmd+Q



[ Reply to This | # ]
10.7: Remove Safari session auto-restore
Authored by: munas on Aug 03, '11 10:32:21PM

is Alt+Cmd+Q not working in that situation?



[ Reply to This | # ]
10.7: Remove Safari session auto-restore
Authored by: bystander on Aug 04, '11 02:06:49AM

Another workaround is to turn on private browsing, then restart. It opens the new tab/top sites page, not your last visited one.



[ Reply to This | # ]
10.7: Remove Safari session auto-restore
Authored by: jared_e42 on Aug 04, '11 07:53:22AM

If you wish to disable the auto-resume; go to System Preferences: General (the check box to turn it off/on system wide is under the recent items).

However, there appears to be a bug in 10.7.0, as Safari still auto-opens the windows. Our Apple Rep at UCLA has made a bug report to Apple.

I also suggested that having it be an app by app preference would be far more useful, as many programs I would like to have that ability, but others I do not.



[ Reply to This | # ]
10.7: Remove Safari session auto-restore
Authored by: tiocsti on Aug 05, '11 08:10:57AM
A simpler way is to defaults write com.apple.Safari NSQuitAlwaysKeepsWindows -bool false

~ @tiocsti

[ Reply to This | # ]

10.7: Remove Safari session auto-restore
Authored by: rejetton on Aug 05, '11 07:40:18PM

I'm the original poster, and I want to thank each of you for your remarks. Also,

1. It is correct that I removed a directory (and its contents) and not just a file as I wrote. In fact, I used (command line) rm with the recursion and force flags. If you do that too, please be careful.

2. It is also correct that Cmd+q was not working. I did not try Cmd+Alt+q. As I said, the popup had exclusive focus for the application.

3. As I wrote, I had the System Preferences setting disabled for auto-resume, and had verified it several times with several applications. It came as quite a surprise that Safari insisted on auto-resume after a forced quit. I think this qualifies as a bug. There again, I think auto-resume itself is a bug.

4. I appreciate hearing about using Shift to start an application. That will be useful in the future.

5. Someone mentioned enabling private browsing. I can't quite picture how that would have helped me since I would have had to start Safari to enter private browsing mode, right? And every time I started Safari I got the exclusive focus popup. Or am I missing something? Can you enable private browsing in some other way than using the pull-down menu in Safari?

Again, my thanks go to everyone.



[ Reply to This | # ]
10.7: Remove Safari session auto-restore
Authored by: Michelasso on Aug 08, '11 08:38:10AM

Nevertheless great hint. I was looking exactly for the location where the apps status was saved. Something on my MB was pretty messy on restarting a new session and I wanted to clean it up. Now I removed all subdirs in

"$HOME/Library/Saved Application State"

And the logging in seemed much faster. Especially iStat Menus was taking ages to show the CPU monitor.

I suspect that seen the few bugs in OS X Lion a general clean up once in a while will not hurt. ;)



[ Reply to This | # ]
defaults write worked!
Authored by: bugmenot3823482 on Jun 09, '12 11:36:02PM
A simpler way is to defaults write com.apple.Safari NSQuitAlwaysKeepsWindows -bool false … ~ @tiocsti
Thank you, @tiocsti! That worked perfectly and it was driving me nuts that there was no option in the preferences menu. I almost installed Firefox or Chromium and junked Safari. I'm setting up a new iMac for a 97 year old uncle and he needs the web browser to be as predictable and simple as possible.

[ Reply to This | # ]