Crash with multiple document windows

I’m not sure if it’s me or something with JUCE, but I get an intermittent crash in my plugin (standalone mode) when I close the main window and I have one or more DocumentWindows open. I’m doing a “setVisible(false”) on all of them in the pluginEditor but I’m not sure if this is best practice or not.

The crash happens deep in “void Component::internalHierarchyChanged()” as they are closing but I’m completely at a loss as to how to debug this properly.

Any ideas?

Maybe set the document windows owned content visible(false) then set the document window to false and set the unique ptr to nullptr so there isn’t any leaks?