Close socket when error occured while connectiong. (Fixes #58)