Fix null pointer dereference when server goes away