Electron App - close unless last window


I am using an electron app (Notion) and the default behavior is to close the window on CMD + W. Normally not a big deal but then it needs to re-load once activated (Electron apps...). What I want to do is close windows (because I often have multiple) unless it's the last window - then I want it to hide application.

I played around with a few things but can't seem to find a way to do this.

Any ideas or suggestions? Thanks!


Is this one of the things you tried? It seems to work fine for me with other apps (make sure it's in a Notion-only macro group for best results):

Close Multiple Windows, Hide Last Window.kmmacros (2.7 KB)


@gglick - this is far more sophisticated than anything I tried ;). It worked, thank you so much!