fixed AccessViolationException on DocumentClosed