How could I cancel an animation smoothly?

I am making an fps, and I am trying to animate aiming down sights, and the actual animations are working just fine (before I explain the next part, it is important to note that the animation “AKM ADS” serves as a transition between “Idle” and “AKM ADS 2” which serves as the actual state of aiming), and the transitions are working in the direction indicated by the line in the animator, but when I untoggle the “ADS” boolean via code (by releasing right click) mid “AKM ADS” animation, it first finishes playing and then goes in the opposite direction back to “Idle”, I tried fixing the issue by adding an empty state between “Idle” and “AKM ADS”, and it somewhat worked, it went back when i released right mouse, but it went back abruptly and instantaneously, it wasn’t smooth at all, does anybody know what I could do to make the “AKM ADS” stop mid animation and actually do a smooth transition back to “Idle” mid animation? I don’t care whether its via code or editing the nodes. Thank you for taking the time to read, I appreciate it.

Here is the section of code that controls the “ADS” boolean:

void Update()
        if (Input.GetKey(KeyCode.Mouse1) && !isReloading)
            animator.SetBool("ADS", true);
            animator.SetBool("ADS", false);

As far as I understand, what you want to do is to have a transition interrupt an ongoing animation clip (in your case, a transition from “AKM ADS” to “Idle” would be executed even if the clip has not finished playing).

In your transition inspector (the inspector for a selected transition) there is a toggle called “Has Exit Time”. This controls when the transition gets taken. If “Has Exit Time” is checked, the transition can only be taken when the exit time (by default the end of the clip) is reached. If it is unchecked, the transition will be taken as soon as the conditions are true, regardless of the current time of the clip.

So, all you should have to do is create a transition from “AKM ADS” to “Idle”, give it a reasonable duration so that it is not instant, uncheck “Has Exit Time” so that it can be taken at any time, and finally, add a condition that checks that the ADS parameter is false.

As a side note, if you ever want to interrupt another transition instead of an animation there is also a way to do this.