// Cleanup stuff when closing the window private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) { if (processing_thread != null) { // Stop capture and tracking thread_running = false; processing_thread.Join(); } if (face_analyser != null) { face_analyser.Dispose(); } if (landmark_detector != null) { landmark_detector.Dispose(); } }