Add SIGTERM signal handling for global shutdown.
Include log.h in main.h directly, since everybody uses it.