cleanup logrecordsocket handler and fix bug in on_cancel