fix closing handshake and loss of received data
Merge pull request #424 from nkzawa/patch-2

Fix closing handshake and loss of received data