diff --git a/src/UI/DocumentViews/MpvContainer.cc b/src/UI/DocumentViews/MpvContainer.cc
index c0e3c49b1d7921ea671f041f4520c0e6da3d3618..b63509539601ca142c9a56d4bf4df261d2be0d10 100644
--- a/src/UI/DocumentViews/MpvContainer.cc
+++ b/src/UI/DocumentViews/MpvContainer.cc
@@ -1,5 +1,6 @@
 #include "PreCompiledHeaders.hh"
 #include "UI/DocumentViews/MpvContainer.hh"
+#include "UI/MainWindow.hh"
 
 using namespace Vivy;
 using namespace std::string_literals;
@@ -97,7 +98,17 @@ MpvContainer::closeMpv() noexcept
     }
 }
 
-MpvContainer::~MpvContainer() noexcept { closeMpv(); }
+MpvContainer::~MpvContainer() noexcept
+{
+    if (!(vivyApp->getMainWindow()->isBeingClosed()))
+        closeMpv();
+
+    else {
+        logWarning() << "The main window was already destroyed, "
+                        "don't destroy MPV and let it leak, "
+                        "the OS will collect the garbage.";
+    }
+}
 
 void
 MpvContainer::handleMpvEvent(const mpv_event *const event) noexcept
diff --git a/src/UI/MainWindow.cc b/src/UI/MainWindow.cc
index 6c564ae43eb53b08e71a837693a75f0ccfcde6da..d83a4b4909cb0758a2a60e3a01017af23b3b2594 100644
--- a/src/UI/MainWindow.cc
+++ b/src/UI/MainWindow.cc
@@ -161,10 +161,17 @@ MainWindow::MainWindow() noexcept
     newDocument();
 }
 
+bool
+MainWindow::isBeingClosed() const noexcept
+{
+    return privateIsBeingClosed;
+}
+
 void
 MainWindow::closeEvent(QCloseEvent *event) noexcept
 {
     logDebug() << "Closing the main window!";
+    privateIsBeingClosed = true;
     forEachViews<VivyDocumentView>([](VivyDocumentView *view, int) { view->closeDocument(); });
     QMainWindow::closeEvent(event);
 }
diff --git a/src/UI/MainWindow.hh b/src/UI/MainWindow.hh
index 71dea3cd865cdb80efb063dd2c2c4fb52c1b036f..c462d7f978b5cc9ac8d24de61ea876c05513b95c 100644
--- a/src/UI/MainWindow.hh
+++ b/src/UI/MainWindow.hh
@@ -28,9 +28,13 @@ class MainWindow final : public QMainWindow {
     QMutex aboutWindowMutex;
     AboutWindow *aboutWindow{ nullptr };
 
+    bool privateIsBeingClosed{ false };
+
 public:
     explicit MainWindow() noexcept;
 
+    bool isBeingClosed() const noexcept;
+
     AbstractDocument *getCurrentDocument() const;
     template <class Document> Document *getCurrentDocument() const
     {