That sounds like RxJS race(), and given that it's JS there's often no cleanup needed (and if there is RxJS has easy ways of doing that as well).
https://www.learnrxjs.io/learn-rxjs/operators/combination/ra...
https://www.learnrxjs.io/learn-rxjs/operators/combination/ra...