How to call AudioAppComponent::shutdownAudio() from correct thread?

I have a situation where I would like to do the following:

I am using:

And the lambda function it takes as a parameter needs to call the following method:
void AudioAppComponent::shutdownAudio();

What is the easiest way to ensure that shutdownAudio() gets called in a thread where it is allowed to be called? Currently on some computers that method is called from some incompatible thread which hangs up the software.

I assume shutdownAudio() should be called from:
class MainWindow : public juce::DocumentWindow
which owns the MainComponent which handles audio devices etc.?

Can I just send a message and the ActionListener then calls the shutdownAudio() directly?

I made a quick test and added the following to MainComponent destructor, which gets called by the MainWindow’s destructor when the application is closed:


The assertion doesn’t complain anything, so it seems that at least on my computer the destructor gets called from a message thread. Then that would mean that I can probably safely send a message from the FileChooser::launchAsync() and the one receiving that message can directly call the shutdownAudio().

If I am wrong with my assumption, feel free to correct me.