Fixed crash that occurred while reopening a document after closing another one