Loop 1 sets a local variable (X) to TRUE when it quits.
Loop 2 sees X = TRUE and quits.
You start the program again - BUT X IS STILL TRUE.
Loop 2 finishes before loop 1, sees X = TRUE and quits.
Loop 1 finishes, sets X = FALSE, but it's too late.
You need to set X FALSE, before either loop starts.
You are using code to set X.Visible to FALSE, you can do the same thing by popping up on the X terminal and choosing HIDE INDICATOR - you don't need code to do it.