MessageThread teardown

Hi. This is my second week with JUCE so I’m still getting my bearings but right now I’m running into an issue gracefully shutting down when my app is exited.

I currently have a thread running a loop that checks for MIDI connections and disconnections every half second. The object that handles this has a destructor that tells the loop to stop, therefore allowing the threads to exit before the object is destroyed.
The problem is that the thread runs a callFunctionOnMessageThread and for some reason, if the timing is wrong, the MessageManager will error on the jassertfalse inside that function.

I’m wondering, why is that? Is there a maximum time that things must be torn down in and the half-second sleep in my loop is too much? Or is something destroying the MessageThread independent of the objects that are within the MainComponent?

Ignore this question. I was misusing the Thread module and it was causing some strange behavior.