Supporting graceful signal shutdown.

Adding a signal handler and gracefully shutting down all threads.
Not trying to nit picky, but these are logically errors. It would be better to stick to one style so that we can avoid nit picks in our PRs. I am fine with choosing the existing style.