Hide Safari vs closing if just pinned tabs open

Looking for some help creating a macro that would simply hide safari if I hit CMD + W and all that is open is pinned tabs.

Safari does a good job of protecting pinned tabs (Chrome does not) but it does have to re-load the content on startup. Hiding would further protect that and keep things running. Any idea of how to do that?

Anyone :pray:?

I figured it out!!!