Clear socket on error