diff --git a/cas.module b/cas.module
index 3b84d97..a198490 100644
--- a/cas.module
+++ b/cas.module
@@ -634,10 +634,20 @@ function cas_login_page($cas_first_login = FALSE) {
 }
 
 /**
- * Logs a user out of drupal and then out of cas
+ * Logs a user out of Drupal and then out of CAS.
+ *
+ * @param boolean $mimic_user_logout
+ *   Whether to make a log entry and envoke hook_user_logout(), as is done
+ *   when user_logout() is run.
  */
-function cas_logout() {
-  global $user;
+function cas_logout($mimic_user_logout = TRUE) {
+  if ($mimic_user_logout) {
+    global $user;
+    watchdog('user', 'Session closed for %name.', array('%name' => $user->name));
+    module_invoke_all('user_logout', $user);
+  }
+
+  session_destroy();
 
   // Build the logout URL.
   cas_phpcas_init();
@@ -655,7 +665,7 @@ function cas_logout() {
     $destination = variable_get('cas_logout_destination', '');
   }
 
-  //Make it an absolute url.  This will also convert <front> to the front page.
+  // Make it an absolute url. This will also convert <front> to the front page.
   if ($destination) {
     $destination_url = url($destination, array('absolute' => TRUE));
     $options['query'] = array(
@@ -665,11 +675,6 @@ function cas_logout() {
     );
   }
 
-  // Mimic user_logout().
-  watchdog('user', 'Session closed for %name.', array('%name' => $user->name));
-  module_invoke_all('user_logout', $user);
-  session_destroy();
-
   // Force redirection in drupal_goto().
   unset($_GET['destination']);
   drupal_goto($logout_url, $options);
