use atexit() to terminate log instead log_term().