How to stop player from moving

I have a 2d platformer game, and I want to stop the player from moving when a specific event happens. In this case, the event is a bool called ‘onGame’. Here is my script, or at least what you need to see of it.

private void FixedUpdate()
    {
        if (!OpenGame.gameOn)
        {
            
            float moveInput = Input.GetAxisRaw("Horizontal");
            rb.velocity = new Vector2(moveInput * movementSpeed, rb.velocity.y);

            if (moveInput == 0)
            {
                anim.SetBool("isRunning", false);
            }
            else
            {
                anim.SetBool("isRunning", true);
            }

            if (moveInput < 0 && !facingRight)
            {
                flip();
            }
            else if (moveInput > 0 && facingRight)
            {
                flip();
            }

           
        }
        if (OpenGame.gameOn)
        {
            movementSpeed = 0f;
        }
    }

now for some reason, when gameOn becomes active, if the player was still holding down one of the movement keys, than the player would still continue moving in that direction. I even tried setting the movement speed to 0 to stop the player from moving, but it just doesnt work. Any help is greatly appreciated.

Simple solution to enable Kinematic to prevent Rigidbody velocity. Don’t forget to disable Kinematic to continue movement

        public Rigidbody playerRb;

        public void StopPlayer()
        {
            playerRb.isKinematic = true;
        }

@Smart_GamingYT

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

public class PlayerLife : MonoBehaviour
{
private Rigidbody2D rb;
private Animator anim;
[SerializeField] private AudioSource deathSoundEffect;
//private Rigidbody2D playerRb;
//
private void Start()
{
//rb.isKinematic = false;
rb = GetComponent();
anim = GetComponent();
//playerRb = GetComponent();

    //playerRb.isKinematic = false;
}
private void OnCollisionEnter2D(Collision2D collision)
{
    if (collision.gameObject.CompareTag("Trap"))
    {
        Die();
    }
}
private void Die()
{
    deathSoundEffect.Play();
    //playerRb.isKinematic = true;
    //stop player movement
    rb.velocity = Vector2.zero;
    anim.SetTrigger("death");
}

private void RestartLevel()
{
    SceneManager.LoadScene(SceneManager.GetActiveScene().name);
}

}