How to exit from an interrupt's loop for MSP430
Your microcontroller does exactly what you program it to do. You programmed it to have a tight empty infinite loop, and as the name suggests, an interrupt routine just interrupts the execution, before returning where it left off.
So, this works as designed! If you don't want a while-loop without condition, then don't use one. Instead, you could check whether you're still in state 2.
However, this looks like your state 2 should actually be two different states: the TA0-configuring state, and an &quot;idle&quot; waiting state. After you converted that state to two states, you can just eliminate the inner while-loop, and just iterate through your state machine. Pseudo-code:
Isr_a():
   Change_state;

Isr_b():
   Change_state;

Main():
    Endlessly:
        Case state 0:
            Do this;
        Case state 1:
            Do that;
        Case state 2:
             Setup TA0;
             Change state to 3;
        All other cases:
             (Nothing)
```