Do `quit()` if the system requested the app to close.

This fixes the issue where a system logout was blocked by bitmask since
we were interpreting the closeEvent as if the user clicked on the 'X'
button.
Closes #5870.
Merge remote-tracking branch 'refs/remotes/ivan/bug/5870_bitmask-prevent-system-logout-on-linux' into develop