Ensure TCP connection is closed