If you want to remove an element involved in this animation from the document altogether, doing so before the animation is complete causes the animation to abruptly stop. You should use the Promise to be notified when the animation completes and then remove the element from the document.

The general usage pattern for layout animations such as this function is as follows:

Call the create function (such as the one discussed on this page) and save the result.

Change the document layout as necessary to represent the new state.

Call the execute method on the object you saved in step 1 to perform the animation.