Added a signal handler so that the programs exit gracefully if the user hits
Ctrl-C.