Supporting graceful signal shutdown.

Adding a signal handler and gracefully shutting down all threads.
Good point, done.