u may try to use WM_CLOSE rather than WM_DESTROY.. to close the application. WM_DESTROY doesn't do the necessary cleanup