Improve socket disconnect error handling