In Windows, you use SetConsoleCtrlHandler to trap Ctrl+C.