Should fix #20. Thanks to @stakach's solution :).
Merge pull request #21 from cotag/close-connections-on-threaded-mode

Prevent file descriptor leaking on some platforms, fixes #20