Fix re-opening documents in closed state