Parse Android app - ANR (application not responding) when user logging out

We have a Parse Android that saves location from time to time.

It will login annonymously before saving. If there is any error in saving, which could be due to session related issue, it will try to logout. So next time, it can login again and save the location correctly.

This is the code:

    override fun onLocationChanged(location: Location) {
        ParseAnonymousUtils.logIn { user, e ->
            try {
                if (e != null || user == null) {
                    // do not save location
                } else {
                    // proceed to save location...
                        val currentLocation = ParseObject("Location")
                        currentLocation.put("latitude", location.latitude)
                        currentLocation.put("longitude", location.longitude)                        
                        currentLocation.saveInBackground {
                            if(it != null) {
                                // location save failed, proceed to logout...
                                // location saved successfully
            }catch(e: Exception){

However, on Google Play console, we can see that a small number of devices experiencing ANR (Application not responding) on this method from time to time:$lambda-2$lambda-1
Broadcast of Intent { act=android.intent.action.SCREEN_OFF }

Stack trace on Main thread:

at java.lang.Object.wait (Native method)
  at java.lang.Object.wait (
  at java.lang.Object.wait (
  at bolts.Task.waitForCompletion (
  at com.parse.ParseTaskUtils.wait (
  at com.parse.ParseUser.logOut (
  at$lambda-2$lambda-1 (MainActivity.kt:177)
  at$6KqIzfYp6WAOTt6eGBJqM-j9M90 (unavailable)
  at$$Lambda$MainActivity$6KqIzfYp6WAOTt6eGBJqM-j9M90.done (unavailable:2)
  at$$Lambda$MainActivity$6KqIzfYp6WAOTt6eGBJqM-j9M90.done (unavailable:2)
  at com.parse.ParseTaskUtils$1.done (
  at com.parse.ParseTaskUtils$1.done (
  at com.parse.ParseTaskUtils$2$ (
  at android.os.Handler.handleCallback (
  at android.os.Handler.dispatchMessage (
  at android.os.Looper.loopOnce (
  at android.os.Looper.loop (
  at (
  at java.lang.reflect.Method.invoke (Native method)
  at$ (
  at (

It feels like this ANR is happening when the user turning off the Android screen when the app is running? And therefore the logout is kind of incomplete? Anyone can advise?