I am working with Qt, Directx 11 and C++. When my widget opens I start an Engine with system->Run(). This function calls every frame a function named Frame() as long as the variable done is set to false.

When the closing event is called in my Qt class, then I want to shutdown the engine. So I made a function named isDone() which sets the variable done to false and then I release all variables I have created with System->Shutdown(). But the problem is that the program crashes because when the closing event is called, the System->Run() function is interrupted as long as the closing event is over, but I want that the Run() function is executed after the call from the function isDone() before the System->Shutdown() function is executed.

Is there any possibility to make an interrupt in the closing event, so that other things in the queue are executed?