Wait for goroutines to finish.