catch SIGINT and SIGTERM signals.

do a graceful exit.