Handle Ctrl-C signal to exit loop.