UI: fix CameraView crash on deleting.
diff --git a/selfdrive/ui/qt/offroad/driverview.cc b/selfdrive/ui/qt/offroad/driverview.cc
index 0ff786fb91d3dd..1377bb3b23ba84 100644
--- a/selfdrive/ui/qt/offroad/driverview.cc
+++ b/selfdrive/ui/qt/offroad/driverview.cc
@@ -35,6 +35,7 @@ void DriverViewScene::showEvent(QShowEvent* event) {
 }
 
 void DriverViewScene::hideEvent(QHideEvent* event) {
+  // TODO: stop vipc thread ?
   params.putBool("IsDriverViewEnabled", false);
 }
 
diff --git a/selfdrive/ui/qt/widgets/cameraview.cc b/selfdrive/ui/qt/widgets/cameraview.cc
index a606d6893e1cd2..347cdb1dca88f2 100644
--- a/selfdrive/ui/qt/widgets/cameraview.cc
+++ b/selfdrive/ui/qt/widgets/cameraview.cc
@@ -102,6 +102,7 @@ CameraWidget::CameraWidget(std::string stream_name, VisionStreamType type, bool
 
 CameraWidget::~CameraWidget() {
   makeCurrent();
+  stopVipcThread();
   if (isValid()) {
     glDeleteVertexArrays(1, &frame_vao);
     glDeleteBuffers(1, &frame_vbo);
@@ -171,6 +172,15 @@ void CameraWidget::showEvent(QShowEvent *event) {
   }
 }
 
+void CameraWidget::stopVipcThread() {
+  if (vipc_thread) {
+    vipc_thread->requestInterruption();
+    vipc_thread->quit();
+    vipc_thread->wait();
+    vipc_thread = nullptr;
+  }
+}
+
 void CameraWidget::updateFrameMat() {
   int w = width(), h = height();
 
diff --git a/selfdrive/ui/qt/widgets/cameraview.h b/selfdrive/ui/qt/widgets/cameraview.h
index 0698d1fb9aaac9..7cc3847f99c0ba 100644
--- a/selfdrive/ui/qt/widgets/cameraview.h
+++ b/selfdrive/ui/qt/widgets/cameraview.h
@@ -51,6 +51,7 @@ class CameraWidget : public QOpenGLWidget, protected QOpenGLFunctions {
   void updateCalibration(const mat3 &calib);
   void vipcThread();
   void clearFrames();
+  void stopVipcThread();
 
   bool zoomed_view;
   GLuint frame_vao, frame_vbo, frame_ibo;

The vipc thread should be stopped and deleted before deleting