I couldn't think a better way beside adding an API such as CouchbaseLite.deinit() or .shutdown() to shutdown the executor service. I have thought that maybe we lazy creates the executor and shutdown the executor when there are no database opens. However, this doesn't seem to work well as :
- The executor could be used by non-database components such as C4Log. Maybe we need to list all of these and see if we can avoid using the global executor service or not.
- There is no requirement that the app needs to close the database when exits. Maybe this is required for Java if they want to close the app gracefully beside using System.exit().
The problem about CouchbaseLite.shutdown() is that it cannot be called safety if some components are still using it.