Fix crash when logging at exit time