Support background operations

Add connection timeout to reduce waiting time in case the host name is
not accessible. Stop rows count threads when the table is unselected.