I am trying to figure out which I should be using. On closing my WinForm app fires of a Form in Dialog mode. That form runs a Background worker that Syncs the DB with the
Environment.Exit() is used for console apps.
You want to use: System.Windows.Forms.Application.Exit()
By exiting thread, you are only exiting the current thread context, while leaving any started foreground threads running. I suspect the thread that is causing the error is still running, so you've essentially masked the problem, not worked around it. I would try and figure out why you are getting this error "Collection was modified; enumeration operation may not execute." on exit. It's being exposed by Application.Exit(), but it's not caused by it.