waitForSessionsToTerminate

Calling this method will block until all sync sessions for a given App has terminated.

Closing a Realm will terminate the sync session, but it is not synchronous as Realms communicate with their sync session using an asynchronous communication channel. This has the effect that trying to delete a Realm right after closing it will sometimes throw an IllegalStateException. Using this method can be a way to ensure it is safe to delete the file.