Close log even if error happens