Sometimes you really need to be able to abort something that doesn't have abort semantics - in my case, attempts to read files from iCloud containers mid-download on iOS, which can hang until process exit if you initiate them at exactly the wrong time.
So, POSIX's pthread_cancel() to the rescue, with a bunch of attendant boilerplate.
Your project's settings will need some adjustment - allow non-modular includes, defines-module set to YES, a project header file with the required boilerplate, and
In my case, this all lives in a framework project called AppUtils - if it is in the app project, proper, you can use an Objective C bridging header in place of the module map.