handle the back key to stop the animation