facebook/tornado — pull request #390 by ecksor (2011-10-27 01:54:45+00:00)
Title: close websocket even if connection is broken

if iostream is already closed, websocket will never close properly since currently close will always attempt to write websocket close frame marker

example:
https://gist.github.com/1318510