JuceDemo hits assertion in Desktop::~Desktop

I'd like my app to show a modal dialog, however, if I create a DialogWindow by calling LaunchOptions::launchAsync and then immediately hit cmd+Q to quit the app, the Desktop destructor complains that not all the windows on the desktop have been deleted. Fair enough.

I went to the JuceDemo to see how this case should be handled, but found exactly the same error here - if I open the JuceDemo app, navigate to components: Windows, click 'Show Windows', and then hit cmd+Q, the same assert gets triggered.

What's the proper way to handle quitting the app while a modal dialog is being displayed?

If you look at how the Introjucer does it in its systemRequestedQuit() method, it tells any modal windows to exit, and waits for them to do so.

This works, thank you!