test: fix flaky test for issue24491
test: fix flaky test for issue24491

runtime.GC() doesn't guarantee the finalizer has run, so use a channel
instead to make sure finalizer was run in call to "after()".

Fixes #41361

Change-Id: I69c801e29aea49757ea72c52e8db13239de19ddc
Reviewed-on: https://go-review.googlesource.com/c/go/+/254401
Run-TryBot: Cuong Manh Le <54b4457f1dff6823379654eb5867596497ba782f@gmail.com>
TryBot-Result: Gobot Gobot <66cb808b70d30c07676d5e946fee83fd561249e5@golang.org>
Reviewed-by: Matthew Dempsky <e56ac2c500064424afac424d4b5e53bd0570a731@google.com>
Trust: Cuong Manh Le <54b4457f1dff6823379654eb5867596497ba782f@gmail.com>

nawawi/go,CAFxX/go,cloudflare/go,CAFxX/go,golang/go,nawawi/go,CAFxX/go,golang/go,cloudflare/go,cloudflare/go,CAFxX/go,nawawi/go,cloudflare/go,golang/go,nawawi/go,golang/go,cloudflare/go,golang/go,nawawi/go,golang/go,cloudflare/go,CAFxX/go,cloudflare/go,golang/go,nawawi/go,CAFxX/go,golang/go,nawawi/go,nawawi/go,CAFxX/go,CAFxX/go,cloudflare/go