Fix logger being closed inappropriately