diff --git a/include/libcamera/internal/egl.h b/include/libcamera/internal/egl.h
index fb77225ac4..e18bb91f4d 100644
--- a/include/libcamera/internal/egl.h
+++ b/include/libcamera/internal/egl.h
@@ -103,6 +103,7 @@ public:
 	~eGL();
 
 	int initEGLContext();
+	void resetEGLContext();
 	static EGLDisplay probeDisplay();
 
 	int createInputDMABufTexture2D(eGLImage &eglImage, int fd);
diff --git a/src/libcamera/egl.cpp b/src/libcamera/egl.cpp
index 3de5fab816..6b50e7bb77 100644
--- a/src/libcamera/egl.cpp
+++ b/src/libcamera/egl.cpp
@@ -71,14 +71,13 @@ eGL::eGL(EGLDisplay display)
 }
 
 /**
- * \brief Destroy the EGL helper
+ * \brief Release all EGL resources
  *
- * Destroys the EGL context and surface if they were successfully created.
+ * Equivalent to calling resetEGLContext().
  */
 eGL::~eGL()
 {
-	if (context_ != EGL_NO_CONTEXT)
-		eglDestroyContext(display_, context_);
+	resetEGLContext();
 }
 
 /**
@@ -436,6 +435,20 @@ fail:
 	return -ENODEV;
 }
 
+/**
+ * \brief Destroy the EGL context
+ *
+ * This function destroys the EGL context created by initEGLContext().
+ */
+void eGL::resetEGLContext()
+{
+	if (context_ != EGL_NO_CONTEXT)
+		eglDestroyContext(display_, std::exchange(context_, EGL_NO_CONTEXT));
+
+	tid_ = -1;
+	vtable_ = {};
+}
+
 /**
  * \brief Make the EGL context current for the calling thread
  *
