Fix runtime error and test failure for 2.x.

This avoids a nasty "runtime: signal received on thread not created by
Go." when double-closing a 2.x socket into a simple test failure by
simply not closing a socket more than once (unless a socket is closed
from multiple threads at the same time).  It also avoids a test failure
by refusing to attempt to connect a socket that has already been closed.

Tested with 2.2 and 3.2.