Disconnect procedure waits for all threads to join by using counter