Fix client hang when the server goes away