Merge pull request #1 from mihawk/patch-1

fix crash cowboy when socket close
Merge pull request #4 from davidw/master

fix crash cowboy when socket close