void MainWindow::closeEvent(QCloseEvent* event)
{
    if (continueJobsRunning() && continueModified()) {
        if (!m_htmlEditor || m_htmlEditor->close()) {
            LOG_DEBUG() << "begin";
            JOBS.cleanup();
            writeSettings();
            if (m_exitCode == EXIT_SUCCESS) {
                MLT.stop();
            } else {
                if (multitrack())
                    m_timelineDock->model()->close();
                if (playlist())
                    m_playlistDock->model()->close();
                else
                    onMultitrackClosed();
            }
            QThreadPool::globalInstance()->clear();
            AudioLevelsTask::closeAll();
            event->accept();
            emit aboutToShutDown();
            if (m_exitCode == EXIT_SUCCESS) {
                QApplication::quit();
                LOG_DEBUG() << "end";
                ::_Exit(0);
            } else {
                QApplication::exit(m_exitCode);
                LOG_DEBUG() << "end";
            }
            return;
        }
    }
    event->ignore();
}
void MainWindow::closeEvent(QCloseEvent* event)
{
    if (continueJobsRunning() && continueModified()) {
        if (!m_htmlEditor || m_htmlEditor->close()) {
            LOG_DEBUG() << "begin";
            JOBS.cleanup();
            writeSettings();
            if (m_exitCode == EXIT_SUCCESS) {
                MLT.stop();
            } else {
                if (multitrack())
                    m_timelineDock->model()->close();
                if (playlist())
                    m_playlistDock->model()->close();
                else
                    onMultitrackClosed();
            }
            QThreadPool::globalInstance()->clear();
            AudioLevelsTask::closeAll();
            event->accept();
            emit aboutToShutDown();
            if (m_exitCode == EXIT_SUCCESS) {
                QApplication::quit();
                LOG_DEBUG() << "end";
                ::_Exit(0);
            } else {
                QApplication::exit(m_exitCode);
                LOG_DEBUG() << "end";
            }
            return;
        }
    }
    event->ignore();
}