Why hook_user_logout is not working? I am trying to display message or run some other action when user logout and redirect them to home page. I am trying following code, but all I get is just set_message and it never logoff me. why?

/**
 * Implements hook_user_logout().
 *
 */
function ucenter_user_logout($account) {
  drupal_set_message(t('Thanks for visiting, come again!'));
  drupal_goto();
}
Calling drupal_goto(), you are avoiding the session is destroyed. The function that invokes hook_user_logout() (user_logout()) contains the following code.

  watchdog('user', 'Session closed for %name.', array('%name' =&gt; $user-&gt;name));
  module_invoke_all('user_logout', $user);

  // Destroy the current session, and reset $user to the anonymous user.
  session_destroy();

  drupal_goto();


drupal_goto() calls drupal_exit(), which means that with your Drupal's execution is interrupted before session_destroy() is called.

What you can do is changing the code to something similar to the following one.

function ucenter_user_logout($account) {
  user_cookie_save(array('ucenter.logoff' =&gt; '1'));
}

function ucenter_init() {
  // Check the value of the cookie Drupal_visitor_ucenter_logoff
  // and print the message if the user precedently logged off.
}