Close socket before throwing an exception when bind fails.