fix(client): handle remote terminal hangup (#2827)