By catching the SIGINT
handler, you are preventing the default behaviour, which is to quit the process. When you use Ctrl+C
the second time, the process dies because server.close
throws an uncaught exception.
Just add a process.exit()
to the end of your SIGINT
handler to quit the process gracefully.