Either way you will most likely benefit from running your clean up on a secondary thread. You will most likely not be able to use your second option though:
Per the Apple docs in relation to applicationWillTerminate
:
Your implementation of this method has approximately five seconds to perform any tasks and return. If the method does not return before time expires, the system may kill the process altogether.
One option you could use is cleaning up in applicationDidEnterBackground:
but that also has some complications:
Your implementation of this method has approximately five seconds to perform any tasks and return. If you need additional time to perform any final tasks, you can request additional execution time from the system by calling beginBackgroundTaskWithExpirationHandler:. In practice, you should return from applicationDidEnterBackground: as quickly as possible. If the method does not return before time runs out your app is terminated and purged from memory.
This may be a better solution and you can dig into some recommendations via the documentation I linked to. It would probably easiest though to do it during application launch.