Fixed SIGTERM/SIGINT bug