I've got a Blazor page where the user can start a long-running (~10 minute) process that downloads multiple files from a vendor's API, combines them into a zip archive, and downloads the zip archive to the user's computer. Currently, if the user navigates away from the page, the process continues running but I need it to stop.
I originally thought I could use the beforeunload or unload events but everything I've read says to absolutely not use those. (I have almost no JavaScript experience--that's why we're using Blazor.)
How can I either get a notification that the page has been navigated away from or have the process test to see if the page still exists?
Update
I found NavigationManager.RegisterLocationChangingHandler which works for page navigation but not for closing a tab or refreshing the page. So I still need a way to find out if the page still exists or not.