Start here. This is the direct spoken answer to practice first.
Why this question matters
Hosted services are singletons and do not receive an HTTP request scope. Each independent unit of work needs an explicit lifetime boundary for its scoped dependencies.
I inject IServiceScopeFactory into the hosted service and create a new scope for each job or coherent unit of work. I resolve the scoped handler or DbContext from that scope, await the work, and dispose the scope afterward, using an async scope when dependencies support asynchronous disposal. I do not resolve a scoped service once and store it on the singleton. The stopping token flows into both queue waits and the scoped operation.