tests: Handle unexpected socket connection closure.