Don't constantly loop around when there is an error connecting to Graphi...

...te and also ensure the TCP connection is closed.