issue with res.json followed by res.end call in logout code

 Fixes #550