I have a Safari window on my Mac with multiple tabs. If I press Command-W or click the red Close button instead of pressing Command-Q, the next time I click the Safari icon in the Dock, the tabs are lost. (Yes, I can restore them by clicking "History" > "Reopen Last Closed window" or "Reopen All Windows from Last Session", but this is too easy to forget when I'm in a hurry, which is my usual state.)

Is there a way (using Automator, Shortcuts, or something else) to automatically quit Safari (as if I've pressed Command-Q) once I press Command-W or click the red button? So that I don't lose tabs anymore.

edit: Sorry, I need to correct my question. I don't need to quit Safari when I press Command-W (because Command-W is normally used to close the current tab, and I don't want to change this behavior, of course). I only need to quit Safari when I click the red Close button.

  • The tabs are lost because you closed them before [or instead of] quitting. You need to learn to Quit instead. There's no workaround for that other than the one you already have.
    – Tetsujin
    Commented Apr 6 at 7:00

1 Answer 1


I use the utility app Swift Quit for this. It can be set to quit all or a subset of applications when the last window is closed. I use it to quit several but not all apps.

Thus for your use case this would only work if you are closing the last Safari window.

You must log in to answer this question.