Close the document when done.

Change-Id: Iad20ac5533a46a74642093c686e0941fb3bd29e3
(cherry picked from commit 68749283bc9da3c0422df0d22ad1d2f514d0250d)