fix connection threads tracking leak

- the `@client_threads` array was growing indefinitely with every tcp connection
- better error handling
- proper socket closing exception rescue
- minor optimizations

relates to https://logstash.jira.com/browse/LOGSTASH-2168 and #1509