Give the gift of Drupal. All merchandise is 50% off through 2016.
The code in masquerade_user_logout($account) contains
The users could not logout back to their original user. I changed the code to the following and users could logout without problems using the standard Drupal logout menu entry.
An alternative might be to load $account->masquerading in hook_user_load.