This is an example graceful terminating console application for Windows.
This shows how an console application can graceful terminate itself upon receiving a CTRL+C/CTRL+BREAK/CTRL_CLOSE_EVENT/CTRL_LOGOFF_EVENT/CTRL_SHUTDOWN_EVENT.
This should be compiled with GCC from MinGW-w64. From a MSYS2 (available as a chocolatey package too) console run:
pacman --noconfirm -Sy mingw-w64-x86_64-gcc make zip
export PATH="/mingw64/bin:$PATH"
make