Catch SIGTERM to allow ourselves to do an orderly shutdown. This isn't
useful in general operation (as a TERM will do all this cleanup anyway)
but allows for testing under valgrind to ensure no leaks or invalid
accesses.
Rather than hard coding all of the relevant details allow them to be
specified on the command line. Refactor config into a single config
structure to help with this.