Fix an AttributeError in WebSocketClientConnection._on_close.

Fix an issue that was preventing this issue from showing up in my
tests.

Closes #1140.