Supporting graceful signal shutdown.

Adding a signal handler and gracefully shutting down all threads.
Ok. Lets stick to that.