Close socket in test case