void exitFunc(void) { // Close any open COM ports cmt3.closePort(); // get rid of keystrokes before we post our message while (_kbhit()) { _getch(); } // wait for a keypress if (!g_userQuit) { printf("Press a key to exit\n"); _getch(); } if(g_outputFile != NULL) { fclose(g_outputFile); } }