Reworked thread exit procedure for SIGINT