diff --git a/password_policy.module b/password_policy.module
index c4480a8..0e3aad2 100644
--- a/password_policy.module
+++ b/password_policy.module
@@ -994,11 +994,15 @@ function _password_policy_block_account($account) {
       ->condition('uid', $account->uid)
       ->execute();
 
-    if (db_select('password_policy_expiration', 'p', array('target' => 'slave'))
+    // Check if user is already blocked
+    $blocked = db_select('password_policy_expiration', 'p', array('target' => 'slave'))
       ->fields('p', array('pid'))
       ->condition('uid', $account->uid)
+      ->isNull('unblocked')
       ->execute()
-      ->fetchCol()) {
+      ->fetchCol();
+
+    if (count($blocked)) {
       db_query("UPDATE {password_policy_expiration} SET blocked = %d WHERE uid = :uid", time(), array(':uid' => $account->uid));
     }
     else {
@@ -1007,8 +1011,10 @@ function _password_policy_block_account($account) {
 
     watchdog('password_policy', 'Password for user %name has expired.', array('%name' => $account->name), WATCHDOG_NOTICE, l(t('edit'), 'user/'. $account->uid .'/edit'));
 
-    include_once(drupal_get_path('module', 'user') .'/user.pages.inc');
-    user_logout();
+    if (!function_exists('drush_verify_cli') || !drush_verify_cli()) {
+      include_once(drupal_get_path('module', 'user') .'/user.pages.inc');
+      user_logout();
+    }
   }
 }
 
