Fix #358: NullReferenceException on closing dirty xml file