Love that Safari 9 has pinned tabs, it was the last piece that enabled me to switch from Chrome. However, I often close all tabs except the pinned tabs. However, unless I make one of the pinned tabs active and then close the other tabs it closes the whole window, pinned tabs and all.

For example, let's say I have one pinned tab and one not. If the unpinned tab is active and I hit command+w the whole window closes. But if I make the pinned tab active and then click the close button on the unpinned tab, the window stays open. Any way to keep the window open as long as there are any tabs open, pinned or otherwise?

  • 1
    Sounds like a bug to me. I recommend you use the Feedback form to report. – user11633 Oct 6 '15 at 20:28
  • @Phong I think this is actually intended behavior since opening a new window after accidentally closing a window includes the pinned tabs. That eases the pain, but it's still really weird and different than all other browsers with pinned tabs. – donut Oct 6 '15 at 22:00
  • 3
    @Phong Also, good idea. I've reported this issue. – donut Oct 6 '15 at 22:08
  • @donut I don't think is the intended behavior. Every time the window closes and you open a new one, the tabs loads the pages again. Is really frustrating. And if they are pinned, is because I don't want to close them xD – David Morabito Oct 24 '15 at 0:08
  • @Dave Please report the issue using Feedback Assistant. The more people reporting it the higher chance it'll get changed. – donut Oct 25 '15 at 2:13

If you watch the File menu, you can see W changes depending on the number of open tabs. If there are multiple, it's "Close Tab", if there is one (not counting the pinned), it's "Close Window".

There is a workaround! You can overwrite W to always execute "Close Tab".

Go to System Preferences > Keyboard > Shortcuts > App Shortcuts

Add a Shortcut for the application "Safari", menu item "Close Tab", shortcut w.

If you're not using English in Safari, lookup the exact name of the menu item for closing a tab. In the Dutch version of Safari, the menu item is called "Sluit tabblad".

| improve this answer | |
  • 1
    Should mention that this fix has the side effect of not allowing you to close the last tab in any open Safari window, so even windows without pinned tabs can't be closed using ⌘W. – Brian Donahue Jan 22 '18 at 16:49
  • 4
    This is a great trick. And you can close the window, you just have to use Command-Shift-W to do so. I like that, because it makes the act of closing the window explicit rather than contextual. – GuyGizmo Mar 15 '18 at 0:23

Just want to add to hachre's answer that you can achieve the same result using terminal. For overwrite ⌘W in Safari execute following lines:

defaults write com.apple.Safari NSUserKeyEquivalents -dict-add 'Close Tab' '<string>@w</string></dict>'
defaults write com.apple.universalaccess com.apple.custommenu.apps -array-add '<string>com.apple.Safari</string>'

Then reload Safari:

killall Safari
open -a Safari

I use that commands in Sierra - works great.

| improve this answer | |
  • 1
    You missing an opening <dict> tag? so second arg in the first command would be '<dict><string>@w</string></dict>' – rudolph9 Sep 17 '18 at 17:29
  • @rudolph9 it seems that you are right. but now there is option to set com.apple.Safari in new way: defaults write com.apple.safari NSUserKeyEquivalents '{"Close Tab"="@w";}' and it works. The bad news is that I cannot find a simple way to write to com.apple.universalaccess (defaults write com.apple.universalaccess "com.apple.custommenu.apps" -array-add "com.apple.Safari" just caused error and did nothing with sudo) – zhukov.ever Jan 23 '19 at 20:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .