How to stop movement when hitting a wall

Hi, so when my character hits a wall, it stops him but he acts all jittery because he is still trying to get through. How do I stop it? The movement is automatic. Thanks for all the help!

Here is my code

[SerializeField] float Speed = 3.5f;

Rigidbody rigidbody;

Collision collision;
// Use this for initialization
void Start () {
    rigidbody = GetComponent<Rigidbody>();
}

// Update is called once per frame
void FixedUpdate() {
    Invoke("Rotate", 2f);
}

void Rotate()
{
    if (Input.GetKeyDown(KeyCode.LeftArrow))
    {
        transform.eulerAngles = new Vector3(0, 180, 0);
    }
    else if (Input.GetKeyDown(KeyCode.RightArrow))
    {
        transform.eulerAngles = new Vector3(0, 0, 0);
    }
    else if (Input.GetKeyDown(KeyCode.UpArrow))
    {
        transform.eulerAngles = new Vector3(0, -90, 0);
    }
    else if (Input.GetKeyDown(KeyCode.DownArrow))
    {
        transform.eulerAngles = new Vector3(0, 90, 0);
    }
    rigidbody.transform.Translate(Vector3.forward * Speed * Time.deltaTime);
}

}
I don’t know what I am doing wrong.

I am not 100% confident in this answer, but hopefully it drives you towards a solution.

If you apply force to the rigidbody as opposed to just moving it, it will stop once it can’t move forward any more. Most people on this answer system always seem to warn against not using AddForce.

The “correct” way:

AddForce( transform.forward * forceAmount );