Make socket_partial_close tidier