portal: Check if the monitor is closed before emitting progress

`emit_progress` is called from a thread while another thread could
unexport/close the GDbusInterfaceSkeleton. If that happens, the
connection becomes NULL which is illegal for
`g_dbus_connection_emit_signal` which results in dereferencing an unset
error.

The fix is to lock the UpdateMonitorData, and then only emit the signal
if it is not closed.

(cherry picked from commit ce4a27e1fe):
This commit is contained in:
Internal Server Error - Gitea: Git with a cup of tea
500 Internal Server Error

Gitea Version: 1.28.0+dev-477-g8b6ad49a5f