added code explicitly to disconnect.