Add event beforeLogout.