title: Xamarin NullReferenceException when calling 'Finish()' on activity
body: <p>I created a biometric authentication service that starts an activity and registers a callback to a static <code>EventHandler</code> for the result.</p>
  <p>The handler:</p>
  <pre><code>public class BiometricHandler : IBiometricHandler
  {
      private TaskCompletionSource&lt;byte[]&gt; taskCompletionSource;
  
      public Task&lt;byte[]&gt; StartBiometricAuth()
      {
          Intent intent = new Intent(Android.App.Application.Context, typeof(BiometricActivity));
          intent.AddFlags(ActivityFlags.NewTask);
          Android.App.Application.Context.StartActivity(intent);
  
          taskCompletionSource = new TaskCompletionSource&lt;byte[]&gt;();
          BiometricActivity.BiometricEventHandler += BiometricCompleted;
  
          return taskCompletionSource.Task;
      }
  
      private void BiometricCompleted(object sender, BiometricEventArgs e)
      {
          taskCompletionSource.SetResult(e.Success ? e.Payload : new byte[] { });
  
          BiometricActivity.BiometricEventHandler -= BiometricCompleted;
      }
  }
  </code></pre>
  <p>And the activity (not the actual code obviously):</p>
  <pre><code>public class BiometricActivity : Activity
  {
      public static event EventHandler&lt;BiometricEventArgs&gt; BiometricEventHandler;
      private readonly int BIOMETRIC_REQUEST = 1;
  
      protected override void OnCreate(Bundle savedInstanceState)
      {
          base.OnCreate(savedInstanceState);
  
          Intent intent = new Intent(Application.Context, typeof(BiometricAuth));
          StartActivityForResult(intent, BIOMETRIC_REQUEST);
      }
  
      protected override void OnActivityResult(int requestCode, [GeneratedEnum] Result resultCode, Intent data)
      {
  
          BiometricEventHandler?.Invoke(
              this,
              new BiometricEventArgs(
                  true, new byte[] {1, 2, 3}
              );
  
          Finish();
          
      }
  }
  </code></pre>
  <p>The above code throws a <code>NullReferenceException</code>:</p>
  <pre><code>0xFFFFFFFFFFFFFFFF in System.Diagnostics.Debugger.Mono_UnhandledException_internal
  0x1 in System.Diagnostics.Debugger.Mono_UnhandledException at /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/corlib/System.Diagnostics/Debugger.cs:125,4
  0x20 in Android.Runtime.DynamicMethodNameCounter.57
  0x6 in Xamarin.Forms.Platform.Android.PlatformConfigurationExtensions.OnThisPlatform&lt;Xamarin.Forms.Application&gt; at D:\a\_work\1\s\Xamarin.Forms.Platform.Android\PlatformConfigurationExtensions.cs:8,4
  0xC in Xamarin.Forms.Platform.Android.AppCompat.FragmentContainer.OnResume at D:\a\_work\1\s\Xamarin.Forms.Platform.Android\AppCompat\FragmentContainer.cs:126,4
  0x8 in AndroidX.Fragment.App.Fragment.n_OnResume at C:\a\_work\1\s\generated\androidx.fragment.fragment\obj\Release\monoandroid12.0\generated\src\AndroidX.Fragment.App.Fragment.cs:2570,4
  0x11 in Android.Runtime.DynamicMethodNameCounter.57
  </code></pre>
  <p>And the console:</p>
  <pre><code>**System.NullReferenceException:** 'Object reference not set to an instance of an object.'
  </code></pre>
  <p>I narrowed it down to the <code>Finish()</code> method.
  There is no exception when it is not called.</p>
  <p>I tried calling <code>Finish()</code> from the handler using <code>BroadcastReceiver</code>, same result.</p>
  <p>Why does <code>Finish()</code> throw this exception?</p>