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.setACL(ParseACL(ParseUser.getCurrentUser()));
                        currentLocation.saveInBackground {
                            if(it != null) {
                                // location save failed, proceed to logout...
                                ParseUser.logOut();
                            }else{
                                // 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:

com.company.app.view.MainActivity.onLocationChanged$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 (Object.java:442)
  at java.lang.Object.wait (Object.java:568)
  at bolts.Task.waitForCompletion (Task.java:182)
  at com.parse.ParseTaskUtils.wait (ParseTaskUtils.java:29)
  at com.parse.ParseUser.logOut (ParseUser.java:993)
  at com.company.app.view.MainActivity.onLocationChanged$lambda-2$lambda-1 (MainActivity.kt:177)
  at com.company.app.view.MainActivity.lambda$6KqIzfYp6WAOTt6eGBJqM-j9M90 (unavailable)
  at com.company.app.view.-$$Lambda$MainActivity$6KqIzfYp6WAOTt6eGBJqM-j9M90.done (unavailable:2)
  at com.company.app.view.-$$Lambda$MainActivity$6KqIzfYp6WAOTt6eGBJqM-j9M90.done (unavailable:2)
  at com.parse.ParseTaskUtils$1.done (ParseTaskUtils.java:75)
  at com.parse.ParseTaskUtils$1.done (ParseTaskUtils.java:72)
  at com.parse.ParseTaskUtils$2$1.run (ParseTaskUtils.java:116)
  at android.os.Handler.handleCallback (Handler.java:942)
  at android.os.Handler.dispatchMessage (Handler.java:99)
  at android.os.Looper.loopOnce (Looper.java:226)
  at android.os.Looper.loop (Looper.java:313)
  at android.app.ActivityThread.main (ActivityThread.java:8741)
  at java.lang.reflect.Method.invoke (Native method)
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:571)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1067)

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?