Depending on how you created the Captivate file, you can have the JavaScript execute when the animation ends. Check the Preferences of the file in Captivate and under the Project section there is a start/end feature. This is where you can set the JavaScript to run at the end of the animation.