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.

(cherry picked from commit 76bdf523981d2bd983dac4e01bc5cc934118a73f)

Conflicts:
	sc/source/ui/app/inputhdl.cxx

Change-Id: Ib6e370037ab6097c9c6eff8035249663944b3a6c
Reviewed-on: https://gerrit.libreoffice.org/8055
Tested-by: Caolán McNamara <caolanm@redhat.com>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>