Helworld.c calls the CleanUp function when it receives a WM_DESTROY message or after several consecutive unsuccessful attempts to call the RenderLoop function.
/////////////////////////////////////////////////////////////////////
//
// CleanUp
// Release all D3DRM objects and set the bQuit flag.
//
/////////////////////////////////////////////////////////////////////
void
CleanUp(void)
{
myglobs.bInitialized = FALSE;
myglobs.scene->lpVtbl->Release(myglobs.scene);
myglobs.camera->lpVtbl->Release(myglobs.camera);
myglobs.view->lpVtbl->Release(myglobs.view);
myglobs.dev->lpVtbl->Release(myglobs.dev);
lpD3DRM->lpVtbl->Release(lpD3DRM);
lpDDClipper->lpVtbl->Release(lpDDClipper);
myglobs.bQuit = TRUE;
}