Best Practice for Stopping Background Threads on Quit or Game Crash?

Per title - what is the best practice for ensuring non-main thread methods and processes get stopped if the player exits the game or the game crashes?

For a simple game exit is there something equivalent to the Start() function that I can call after they hit “exit to desktop” for example? That will run cleanup on things?

And then for a crash how would I ensure everything related to my game is stopped on crash?

Pretty sure the OS handles most of this at sigterm / sigkill time.

Do you see otherwise?