Animation works when game starts but wont stop moving the character

Animation works when game starts but wont stop

Here is my code:

using System.Collections;
using System.Collections.Generic;
using System.Diagnostics.Eventing.Reader;
using UnityEngine;

public class Player : MonoBehaviour
{
    public float moveSpeed = 5f;
    public float jumpForce = 5f;
    private Rigidbody2D rb;
    public Animator animator;

    // Variables to track animation states
    private float speed;
    private bool isOnGround;
    float horizontalMove=0f;    
    private void Start()
    {
        rb = GetComponent<Rigidbody2D>();
        animator = GetComponent<Animator>();
    }

    private void Update()
    {
        float moveInput = Input.GetAxis("Horizontal");
        rb.velocity = new Vector2(moveInput * moveSpeed, rb.velocity.y);
        speed = Mathf.Abs(moveInput); // Update speed for the animator

        if (Input.GetButtonDown("Jump") && isOnGround)
        {
            rb.AddForce(new Vector2(0, jumpForce), ForceMode2D.Impulse);
        }

        // Update the Animator parameters
        animator.SetFloat("speed", Mathf.Abs(horizontalMove));
        animator.SetBool("isOnGround", isOnGround);
        
    }

    private void OnCollisionEnter2D(Collision2D collision)
    {
        // Assuming your ground objects have a specific tag
        if (collision.gameObject.CompareTag("Ground"))
        {
            isOnGround = true;
        }
    }

    private void OnCollisionExit2D(Collision2D collision)
    {
        if (collision.gameObject.CompareTag("Ground"))
        {
            isOnGround = false;
        }
    }
}

Can someone take a look at this? Been stuck on this for hours.