Set 'connected' to False when connection is closed.