Improve logout action and fix typo.

Related to #5131.
[Closes #4815]