Made keepalive goroutine stop if connection is lost