bool mainLoopState = true; // Set to false when you want to exit the animation while( mainLoopState ){ /* This is the main animation loop: write rendering logic here */ }