Add option to log debug output.
Close all connections before exiting.

This prevents hangs caused by open proxy command threads.