How do I make the enemy ai stop following the player in the scene properly on unity3d

I have the enemy ai following the play and I nav mesh set to stop in the inspector . The problem is the enemy ai is still following the player regardless if its dead or alive . I want the enemy ai to die where its at. I have it to where the enemy ai is checking to see if the player is near. Here is my script :

using UnityEngine;
 using System.Collections;
 
 public class Enemyai : MonoBehaviour {
 public Transform player;
 static Animator anim;
 public NavMeshAgent nav;               
     void Start () 
     {
             anim = GetComponent<Animator> ();
     }
     
 
     void Update () 
     {
         if (Vector3.Distance(player.position, this.transform.position) < 13)
         {
             Vector3 direction = player.position - this.transform.position;
             direction.y = 0;
             
             this.transform.rotation = Quaternion.Slerp (this.transform.rotation,Quaternion.LookRotation(direction), 0.1f);
			 
			 anim.SetBool("isIdle",false);
             if(direction.magnitude > 2.6 )
             {
              nav = GetComponent <NavMeshAgent> ();
	          nav.SetDestination (player.position);
                  anim.SetBool("isMoving",true);
                 anim.SetBool("isAttack",false);
                 }
			 else
             {
                 anim.SetBool("isAttack",true);
                 anim.SetBool("isMoving",false);
                 
             }
         }
        else
        {
            anim.SetBool("isIdle",true);
            anim.SetBool("isMoving",false);
            anim.SetBool("isAttack",false);
            
        }
     
     
     }
 }

Ok, I misunderstood you in your previous question.
If you want your Enemy GameObject to continue existing even after death, but want it to stop moving, add the following function in you original EnemyAI script:

public void Die(){
    //Disable all animations on the enemy AI
    anim.SetBool("isIdle",true);
    anim.SetBool("isMoving",false);
    anim.SetBool("isAttack",false);
    //Stop the navMeshAgent
    nav.Stop();
    //Remove the AI script (the enemy is dead now)
    Destroy(this);
}

If you want to completely destroy the gameobject, add this function instead

public void Die(){
    //Destroy the enemy gameobject
    Destroy(gameObject);
    
}

In your enemy AI Health script you posted, add the following lines at the end of DieLocal()

GetComponent<Enemyai>().Die();