title: How do I stop a CoroutineCancellationException from causing an activity to not finish?
body: <p>I am getting quite a bit of fatal crash reports in Crashlytics, which seems to be caused by a coroutine cancelling.  And I have no idea on how to remedy it, and have been unable to reproduce it.</p>
  
  <p>The error in Crashlytics is:</p>
  
  <pre><code>Fatal Exception: java.lang.RuntimeException: Unable to destroy activity {...ui.main.MainActivity}: kotlinx.coroutines.JobCancellationException: Job was cancelled; job=SupervisorJobImpl{Cancelled}@1ad5bcf
         at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:4682)
         at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:4700)
         at android.app.servertransaction.DestroyActivityItem.execute(DestroyActivityItem.java:39)
         at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:145)
         at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:70)
         at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1926)
         at android.os.Handler.dispatchMessage(Handler.java:106)
         at android.os.Looper.loop(Looper.java:214)
         at android.app.ActivityThread.main(ActivityThread.java:6981)
         at java.lang.reflect.Method.invoke(Method.java)
         at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
         at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1445)
  </code></pre>
  
  <p>and</p>
  
  <pre><code>Caused by kotlinx.coroutines.JobCancellationException: Job was cancelled
  </code></pre>
  
  <p>My <code>MainActivity</code> doesn't <code>SupervisorJob</code>, but all my <code>Fragment</code>'s extend a base class that has a <code>SupervisorJob</code>.  The base fragment also calls <code>SupervisorJob.cancelChildren()</code> in the <code>onStop</code> method.</p>
  
  <p>Any ideas on how to solve this? Or even how to gather more information about where/why it's happening?  I haven't been able to reproduce it myself, but it is happening quite a bit in the field.</p>