Storport :- Best way to release resources allocated in initialize adapter

Have a physical storport miniport driver.
Driver creates a thread in StorportInitialize routine (at PASSIVE_LEVEL) and some other structures.

The thread can be destroyed by setting an event.

I am confused as to the best place to destroy the thread and its resources.

Is ScsiStopAdapter the best place to intercept this?. This is called at DIRQL and I cannot call KeSetEvent at this level. So I queue a DPC which queues a work item which then destroys the thread by setting the event. But the ScsiStopAdapter has to wait for the thread to be destroyed which means polling.

If I implement it in ScsiStopAdapter, I have to recreate the resources in ReStartAdapter which is also called at DIRQL. The same problem arises.

Should I handle SRB_SHUTDOWN_FUNCTION in BuildIo or StartIO?. We do not set Caches to TRUE. If I set to TRUE, is this SRB guaranteed to be sent.

Any suggestions are welcome.