fdo#73773: Check if the *document* is closing, not the *app*.

Otherwise it would crash if the app has multiple document instances open
and only one of them is being closed.

Change-Id: Ib6e370037ab6097c9c6eff8035249663944b3a6c
(cherry picked from commit 76bdf523981d2bd983dac4e01bc5cc934118a73f)
Reviewed-on: https://gerrit.libreoffice.org/8053
Tested-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com>