I am using SharePoint 2019. I have a site for which I have created several site workflows using the Nintex workflow product. Periodically, there will pe a problem where the workflow internal status shows “Failed on Start (retrying)” and the workflow instance continues to show up under “Running Workflows”, though the workflow appears to work correctly when I check the results. Following is a screen shot:

I am looking for a method of canceling and removing all instances of this workflow (in particular those that show as “running” that are in a “failed on start” condition) in a batch mode with a tool like PowerShell or with some sort of timer job. I want to do this in a batch mode rather than having to go into each job individually and terminate each one. I have found PowerShell scripts to terminate running list workflow instances, but I haven’t found much on site workflows.
A bonus would be to schedule something to run automatically on a periodic basis, but I would be happy to have something I could run manually.
Does anyone have such a script or method for doing this?
Thank you!