Hello @David Thielen,
Welcome to Microsoft Q&A forum.
You can try IHostApplicationLifetime.ApplicationStopping
Triggered when the application host is performing a graceful shutdown. Shutdown will block until this event completes.
Best Regards,
Tianyu