ksherlock 6 days ago

Electron doesn't seem to support it (and even if it did, I suspect most electron developers wouldn't pay it any mind) but...

NSApplicationDelegate's -(BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)sender; method exists so an application can, uhh, automatically terminate after the last window closes.

https://developer.apple.com/documentation/appkit/nsapplicati...

It's not 100% consistent but if you look at Apple's applications based on single window (calculator, system preferences, etc), closing the window quits the app.

2
mort96 5 days ago

Electron doesn't automatically exit when the last window is closed, and the Electron getting started guide (https://www.electronjs.org/docs/latest/tutorial/tutorial-fir...) recommends this code:

    app.on('window-all-closed', () => {
        if (process.platform !== 'darwin') app.quit()
    })
Most Electron apps probably do exactly that. It would feel extremely out of place for a macOS app to quit just because you closed a window.

jonhohle 6 days ago

The function has been available for a while, but auto-closing system apps is a relatively recent change.

I can’t find obvious reference or when Apple started changing this, but it seems related to background app killing that is done now as well. I’m still not sure how I feel about it, but historically that wasn’t common for Mac apps.

wtallis 6 days ago

The ability for an app to keep running without a window was a godsend back in the days when we were all running on hard drives and large apps had splash screens to amuse you during their multi-second launch process. If you were done with a particular document but not done with the application as a whole, you could simply close the window and next time you needed to open a document in that app you wouldn't have to sit through the splash screen again. Unless it was an app with a cross-platform GUI that didn't support this model.

Nowadays, apps closing themselves or being closed by the OS automatically is reasonable in a lot of cases, but Electron apps tend to hit the cases where it still is valuable to operate with the classic NeXT/OS X document-based app paradigm.