Supporting graceful signal shutdown.

Adding a signal handler and gracefully shutting down all threads.
s/Error/error/ here and other places.