672378d202
After I made it so that the encoder internal data gets destroyed when all outputs stop using it (fa7286f8), the media foundation h264 encoder started having crashes on shutdown. After a lot of testing, I realized that the reason it started happening is almost assuredly because active encoding events had not yet been completed. After making it wait on those events by calling DrainEvents(true), the crashes stopped. So asynchronous actions were clearly still occurring and it was shutting down while data was still being processed, thus leading to a crash.