private void OnApplicationShutdown(object sender, ExitEventArgs e) { if (m_filteringEngine != null && m_filteringEngine.IsRunning) { m_filteringEngine.Stop(); } try { SaveProgramState(); } catch (Exception err) { m_logger.Error("Error while saving program state: {0}.", err.Message); } // Dispose all models that implement IDisposable. if (m_modelDashboard != null) { m_modelDashboard.Dispose(); } if (m_modelSettings != null) { m_modelSettings.Dispose(); } WinSparkle.Cleanup(); }