I produce infinite streams for GRDB (database observation never ends), so I'm very eager to test that task cancellation and early loop exit correctly release resources as soon as possible.
Speaking of early exit specifically, I had some success based on the (experimental) fact that the async runtime notifies this termination with the deinitialization of the iterator (deinitialization of the continuation is not observable, so I ignore it). I thus make sure resources that should be released by the end of loop are only retained by the iterator (there), and tests pass.