After your program is finished using IDL it should call IDL_Cleanup(). This allows IDL to exit gracefully. IDL_Cleanup() returns a status value that can be passed to Exit().

int IDL_Cleanup(int just_cleanup);

where:

just_cleanup

If TRUE, IDL_Cleanup() does all the process shutdown tasks, but doesn’t actually exit the process. If FALSE (the usual), the process exits.

Windows applications should place this call in their Main WndProc to be called as a result of the WM_CLOSE message.

switch(msg){
   ...
   case WM_CLOSE: 
     IDL_Cleanup(TRUE);
     any additional processing
     ...