Add a callback for the "end" event