   DXUT calls OnDestroyDevice after WinMain finishes
  Hi!I started to make a program based on EmptyProject, with a class to handle the events like render frame, lost device, etc.After some debugging I've found out, that DXUT calls the event in this order if I simply start and exit the app:-OnCreateDevice-OnResetDevice-...stuff...-WinMain after DXUTMainLoop-WinMain terminates-OnLostDevice-OnDestroyDeviceWhat really surprises me is that OnLostDevice and OnDestroyDevice called after WinMain terminates.Is there a way to force these event to fire before the end of WinMain?I want my myFramework object to handle lost device events, so its myFramework::OnLostDevice method is called from the DXUT event handler, but either I delete the object after the main loop and can't handle the final lost and destroy device, or I can handle the events, but can't delete the object.Or is it okay to put the clean-up part to OnDestroyDevice, since there won't be "recovering" after that?Thanks,shinjin   
  What does the call stack tell you? my guess is that a global is being destroyed and calling those functions as part of its destructor chain.   ;  This is the call stack:Didn't get me any further.;Quote:Original post by crshinjinThis is the call stack:Didn't get me any further."GetDXUTState dynamic atexit destructor" shows that it's a global that's being destroyed. What object is being destroyed there? Is it a global in DXUT, or one you created? Can you clean it up before exiting WinMain() (By calling a Cleanup() or Release() function or something)?   ;Quote:Original post by Evil Steve"GetDXUTState dynamic atexit destructor" shows that it's a global that's being destroyed. What object is being destroyed there? Is it a global in DXUT, or one you created? Can you clean it up before exiting WinMain() (By calling a Cleanup() or Release() function or something)?It's part of the DXUT framework.In the meantime I've realized that DXUTShutdown doesn't actually terminate the program, as the documentation implies, just preform DXUT clean-up. Exactly what I was looking for.So calling DXUTShutdown after the main loop solved my problem.(But it raises the question, if there is a "nice way" to quit from an event hanlder and avoiding stuff like SendMessage( hWnd, WM_CLOSE, 0, 0 );)   