How to animate and then stop animation after reaching destination in a character with navmesh agent?

I just made the script to play the running animation of my character but now i want to it to stop when it reaches it’s destination as any point i click, it should play the idle animation or stop the running one, here’s the script:

using UnityEngine;
using System.Collections;

public class clickToMove : MonoBehaviour
{
UnityEngine.AI.NavMeshAgent navAgent;
Animator anim;
private bool isMoving;
private Vector3 targetPoint;

// Use this for initialization
void Start()
{
    navAgent = GetComponent<UnityEngine.AI.NavMeshAgent>();
    anim = GetComponent<Animator>();
    isMoving = false;
}

// Update is called once per frame
void Update()
{
    RaycastHit hit;
    Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);

    if (Input.GetMouseButtonDown(0)) // 0 is Left-Click, 1 is Right-Click
    {
        if (Physics.Raycast(ray, out hit, 100))
        {
            navAgent.SetDestination(hit.point);
            isMoving = true;
        }
    }

    if (isMoving == true)
    {
        anim.Play("Correr");
    }

    if (transform.position == targetPoint)
    {
        isMoving = false;
        anim.Play("Quieto");
    }
}

}

How can it be done?

This is the code I used hope it helps… @Unidesky

	if (Input.GetMouseButtonUp (0)) 
	{
		if (Physics.Raycast (ray, out hit, 100)) 
		{
			walking = true;
			agent.destination = hit.point;
		}
	}

            if (agent.remainingDistance <= agent.stoppingDistance) 
         {
		walking = false;
	}
        else 
	{
		walking = true;
	}

	anim.SetBool ("isWalking", walking);