For Drupal 8, with drush under Linux (with bash) you can use the following Bash script that requires Drush.solution:
echo 'select name from users_field_data where status=0 and uid!=0' | mysql --silent drupaldatabase > userlist
for username in `cat userlist`; do drush user-cancel $username -y; done
echo 'select name from users_field_data where status=0 and uid!=0' | mysql --silent drupaldatabase > userlist
for username in `cat userlist`; do drush user-cancel $username -y; done
This is both rather slow (1 user/s), but and safe. It doesn't work with names containing spaces or special UTF-8 characterscharacter names and names with spaces.