Create your operations so that they check their isCancelled property at appropriate safe times (at the beginning, after the completion of one stage of the operation, etc.) and exit at that moment. In applicationWillTerminate send your operational queue a -cancelAllOperations message and follow this -waitUntilAllOperationsAreFinished message. This will be blocked until all operations in the queue are completed. This should not slow down the output of the application if all operations handle isCancelled correctly.
Beware that -waitUntilAllOperationsAreFinished when called from applicationWillTerminate will be blocked in the main thread. If any of your operations performs a main thread selector, your application freezes at that point.
source share