Improve logout action and fix typo.

Related to #5131.
[Closes #4815]
Merge remote-tracking branch 'refs/remotes/ivan/bug/5131_mail-starts-after-logout' into develop