Safari greys out the "Close Tab" option when there are only pinned tabs open. This allows a user to change the "Close Tab" behavior using the keyboard shortcuts. I've had this setup for year, so pressing command+w will only close the tabs, not the window.
This is with my shortcut change applied. By default the command+w will show on "Close Window" if there are no tabs or only pinned tabs. By remapping command+w it will only close tabs.

System Preferences > Keyboard > Keyboard Shortcuts... > App Shortcuts
