fix: socket maybe closed when calling ProtocolHandler:setopts; crashing
in that place leads to silent termination, since client will never be
informed. Instead of crashing wait for tcp_closed and cleanup nicely.
fix dialyzer "value is unmatched" warnings
Merge pull request #108 from paulperegud/fix_silent_connection_termination

Fix silent connection termination - thanks Paul