Reduce services stop timeout.
Handle the system's quit correctly.

Use a simple sleep to wait until the services are stopped and then kill
the backend, always in a fixed time in order to avoid blocks/hangs on
the system session logout.

Closes #5870.
Merge remote-tracking branch 'refs/remotes/ivan/bug/fix-system-logout-block' into develop