60

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?

8
  • 1
    Sounds like a bug to me. I recommend you use the Feedback form to report.
    – user11633
    Commented Oct 6, 2015 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
    Commented Oct 6, 2015 at 22:00
  • 3
    @Phong Also, good idea. I've reported this issue.
    – donut
    Commented Oct 6, 2015 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 Commented Oct 24, 2015 at 0:08
  • @Dave Please report the issue using Feedback Assistant. The more people reporting it the higher chance it'll get changed.
    – donut
    Commented Oct 25, 2015 at 2:13

2 Answers 2

102
+50

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".

5
  • 2
    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. Commented Jan 22, 2018 at 16:49
  • 8
    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.
    – Bri Bri
    Commented Mar 15, 2018 at 0:23
  • 1
    Good trick to accidentally close the window but if you have one normal tab left and want to close that, it will still throw you off a little bit. But I guess I'll get used to it :). But still safari should have a native option to keep pinned tabbed windows. Commented Feb 22, 2021 at 20:43
  • 1
    This is so ridiculously stupid. Safari's behavior, not your answer. Thanks for the answer!
    – None
    Commented Jul 13, 2021 at 11:38
  • any fix for ``` Safari not allowing you to close the last tab in any open Safari window. ```
    – fatFeather
    Commented May 2 at 5:48
12

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.

2
  • 2
    You missing an opening <dict> tag? so second arg in the first command would be '<dict><string>@w</string></dict>'
    – rudolph9
    Commented Sep 17, 2018 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) Commented Jan 23, 2019 at 20:16

You must log in to answer this question.

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