Closing Application on macOS

I have an application developed for Windows and now cross-compiled for macOS and Linux.

When user clicks the ‘X’ in the upper left corner of the main window on Windows or Linux, the window and application seem to shutdown, as expected.

However, on macOS, the ‘X’ closes the main window, but the application seems to remain running and continues to show in the task bar.

In Debug mode on macOS, the system seems to call both CancelClose and Close events, but does not completely shutdown.

How do I get the application to completely shutdown on macOS.

Ron Bower
Ellicott City, MD

In your App.Opening event add App.AllowAutoQuit = true as the last line. When the last window is closed the application will Quit.

1 Like

THANKS, Tim - I doubt that I would have ever figured that out without your help.

Does it truly have to be the last line in the opening event ?

Ron

I’ve seen it where if you put AllowAutoQuit before a long process and no window opens in time the app quits too early, so I always put it as the last instruction of whatever opening procedure I’ve created (sometimes there’s an asynchronous chain of events).

2 Likes

In addition to Tim’s answers, I’d just like to point out that this behaviour is the expected one on Mac (for document-based apps). A user may close every window and then want to create a new document from the left-running app.
If you change this behaviour solely because it’s how it works on Windows and Linux, your users may be angry.

2 Likes

Thank you Arnaud - Much appreciated.

In my case it has been more a complaint or observation from macOS users. It is a logging application and users expect the application to shutdown when they close the main window.

Ron

1 Like

Depending on your app design, this may be the correct behavior.

  • Document design; where an application may have more than one editable content window (a document) open at once, it typically will remain open after all the windows are closed. A Text Editing application is typically a “Document” based application.

  • Shoebox design; a single window application, will typically quit when closing the only window. iTunes / Apple Music is considered a Showbox design.

1 Like