Plugin with MidiOutput crashing on exit

I’m writing a VST plugin which creates a virtual MIDI output, the end goal of which is to send things like MIDI clock which normally a VST host would disregard. Anyways, the actual MIDI stuff seems to be working fine, but whenever I remove the plugin I get a crash on destruction. The backtrace looks something like this for the plugin’s thread:

However, the thread that’s crashing is the one created by the MidiOutput object. That thread’s backtrace is very short:

My code is really quite simple. I’ve tried #if 0’ing out pretty much everything except for creating the MIDI output in prepareToPlay(), and the following code in the destructor (btw it also crashes when moved to releaseResources()):

BeatCounterAudioProcessor::~BeatCounterAudioProcessor()
{
    if(virtualMidiOutput) {
        virtualMidiOutput->clearAllPendingMessages();
        virtualMidiOutput->stopBackgroundThread();
        delete virtualMidiOutput;
        virtualMidiOutput = nullptr;
    }
}

What’s going on here? Is this a totally bad idea to try starting a virtual MIDI output from a VST plugin? Or am I just missing something rather obvious?

BTW I should mention that this plugin is open source, if you want to see the full implementation it is located on GitHub in a feature branch.

bump, been nearly a month on this. Should I report a bug in Juce?

If you can point to some juce code and show that it fails to do what it’s supposed to do, then I’ll fix it of course, but you’d have to prove that this isn’t your own bug.

But messing with midi devices in plugins when the host may also be using them is likely to be risky, so you’re really on your own with that!