Touch input not working properly.

Hello. I have GUITexture working as touch button.

for (var touch : Touch in Input.touches) 
    if (myButton.HitTest(touch.position))
        if(touch.phase == TouchPhase.Began) { /* do stuff */ }
        if(touch.phase == TouchPhase.Ended) { /* stop doing */ }

The button works as it should when I press it, and then let go.
But the problem is that if I begin touching the button, and then slide my finger off the button and let go the finger somewhere else, it is still “doing stuff”, but I want it to stop doing it.
I have also tried other touchPhases, but nothing seem to work.
Any help would be appreciated a lot, thanks in advance.

You shall remember number of a finger in case of a touch then normally to execute Ended. You can look at my pregoing response or a code below:

 public var myButton: GUITexture = null;
 var finId1: int = -1; //id finger for cancel touch event

 function Update() {
  for (var touch : Touch in Input.touches) { 
   if (touch.phase  == TouchPhase.Began && myButton.HitTest(touch.position) && finId1 == -1) {
    finId1 = touch.fingerId; //store Id finger
    //Do stuff
   if (touch.phase == TouchPhase.Ended) { //correct code
    if(touch.fingerId == finId1) { //check id finger for end touch
     finId1 = -1;
     //Stop doing

I hope that it will help you.