I have main_activity and dashboard_activity, on dashboard_activity I added fragment using code in OnBackPressed() method

public override  void OnBackPressed()
    {
         //base.OnBackPressed();
             FragmentTransaction transaction =FragmentManager.BeginTransaction();
             Dialog dialog = new Dialog();
             dialog.Show(transaction,"dialog_fragment");
    }

My fragment code is here

class Dialog:DialogFragment
{
    private Button btnExitapp;
    private Button btnLogOut;

    public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
    {
         base.OnCreateView(inflater, container, savedInstanceState);
        var view = inflater.Inflate(Resource.Layout.dialog, container,false);

        btnExitapp=view.FindViewById

Note:My code for btnExitapp work fine only once after deployment and if I reopen the app in emulator and press btnExit it close app and reopen with Dashboard_Activity instead of closing app.

Please guide me to achieve that when BtnLogout pressed, should go back to Main_Activity as it work on backpress button and when BtnExitapp pressed should close the app