Boolean to the rescue
If you want the animation to play through to the end no matter when the button is pressed, create a variable with a boolean value(true or false). You can check that variable at the end of your animation to tell it to replay or do something else. Example....
Last frame of animation.....
//variable set to true loops the animation
//variable set to false, do something else