Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

Safari used to have a preference option to confirm before quitting, now that has disappeared. It's so easy to quit accidentally and lose all your tabs. I know you can resume or re-open the previous session, but those are not solutions to the problem.

How do I make Safari ask me before quitting?

share|improve this question
    
Why isn't Safari automatically re-opening all tabs and content not good enough? Also - have you considered opening a tab like this site and starting to ask a question which forces Safari to pop up a close warning? You'll get a "are you sure you want to leave this page" warning when the time to quit arrives. –  bmike Jun 29 '13 at 19:20
    
The page-with-close-dialog trick from @bmike is a good idea. But will this dialog always be asked at the beginning of the quit operation ? If Safari begins to close the tabs and asks the dialog only after some tabs have been closed, then Josh is screwed. By the way, something to remember : for this page-with-close-dialog trick to work, JavaScript must be turned on. –  Nicolas Barbulesco Jun 30 '13 at 9:54
    
@bmike - Alas, Safari does not restore form data. This is a big hole in Safari's shoes. –  Nicolas Barbulesco Apr 3 at 11:57
1  
@NicolasBarbulesco That is a very good example of the pain of using a web browser in place of a native app. I don't think there's a one-size-fits all solution for when a text entry field should be treated as durable or ephemeral. –  bmike Apr 3 at 13:32
    
@bmike - I agree, the Web is over-rated, glory to native apps ! However, many native apps also have crappy, or even non-existent, restoration of user data. –  Nicolas Barbulesco Apr 8 at 8:58

3 Answers 3

The setting was called "Confirm before closing multiple tabs or windows", but it was removed in 10.7 when Resume was introduced. defaults write com.apple.Safari ConfirmClosingMultiplePages -bool true doesn't work anymore either.

The part of Resume where application state is kept after quitting was disabled by default in 10.8, but you can reenable it from the General preference pane:

You can also enable it in just Safari by running defaults write com.apple.Safari NSQuitAlwaysKeepsWindows -bool true and quitting and reopening Safari.

Safari will still reload tabs when they are restored. And restoring state has only worked about half of the time for me since Safari 6 or 10.8.

You might also change the shortcut for quitting Safari:

Or disable some of the shortcuts completely:

defaults write com.apple.Safari NSUserKeyEquivalents -dict 'Quit Safari' '\0' 'Close Window' '\0' 'Close All Windows' '\0'

share|improve this answer
    
Great tip @Lauri! I often accidentally cmd+Q instead of cmd+W, and Resume doesn't remember which windows were in which Space, so I have to manually reshuffle them every time. Remapping the Quit command solved it. –  wst Aug 28 '13 at 21:13

In the History menu, you have the new option to "Restore last window closed" on top of the previously existing "Restore all windows from previous session".

share|improve this answer

The fact that Safari doesn't "ask" before closing when multiple tabs exist: 1. Not "asking" is a nuisance. My spouse, who is not too tech davy, never seems to notice that there are multiple tabs open. She just clicks the close button, generally intending to close only the active tab. 2. Even when there is just one tab in use, it should be possible to close using the little gray x in the tab as is done for each tab when there is more than one. That would make things self-consistant. One then could close tabs, one by one, including the last one which would result in the whole window being closed (the same as when the red x is clicked). 3. For those who don't like to receive a warning, let them have a way within Safari Preferences to opt out. But the default should be to warn.

Making things self-consistant is the most compelling of all reasons. It's good design practice, folks.

share|improve this answer
1  
Please refrain from discussing your opinions on design and "why" the poster is asking the question, unless it pertains directly to the answer (or expands on it). In this case, it serves no purpose. We like to see direct answers, not monologues on what they should (or shouldn't) be asking the question. This place is about getting answers. I hope you can appreciate how frustrating it can be to ask a question and have dozens of people respond with their opinions rather than simply supply the answer (as is found on many online forums). Thanks again for participating, but please, keep it on point. –  cksum Jan 31 at 22:53

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.