Dispose document when done

Change-Id: I7b15220568717e159f119e79da0016cbc88873cf