How to do something in my PlayableBehaviour when I reach the end of the clip?

So I would like to make a simple thing: Display a text with a clip, if the mouse is clicked, I want to skip to the end of the clip, and when I reach the end of the clip, if the mouse wasn’t clicked yet, I pause the director until the click finally happens.

Here’s what I have thus far. When the behaviour starts playing, I start a coroutine that waits for the click and skips to the end when it happens.
now I would like to find a way to check at the end of the clip if the mouse was pressed, and if it wasn’t, pause (until it’s finally pressed).

There’s unfortunately no such thing as an “OnBehaviourEnd” callback, so I have no idea how to do this.
Pretty sure checking for the current time in ProcessFrame is a bad idea because it will probably never be called exactly at the end of the clip.

   public class WaitForClickBehaviour : PlayableBehaviour
    {
        public PlayableDirector director;
        private bool _wasCLicked = false;
        private bool _skipped = false;
        private PlayableGraph graph;
        private Playable thisPlayable;

        public override void OnPlayableCreate(Playable playable)       
        {
            graph = playable.GetGraph();   
            thisPlayable = playable;
        }
       
        public override void OnBehaviourPlay(Playable playable, FrameData info)
        {
            GameManager.Instance.StartCoroutine(WaitForClick());
        }

        public override void ProcessFrame(Playable playable, FrameData info, object playerData)
        {
           
        }

        private IEnumerator WaitForClick()
        {
            while (Input.GetMouseButtonDown(0) == false)
            {
                yield return null;
            }
            _wasCLicked = true;
            JumpToEndofPlayable();
        }

        private void JumpToEndofPlayable()
        {
            graph.GetRootPlayable(0).SetTime(graph.GetRootPlayable(0).GetTime() + thisPlayable.GetDuration());
        }
    }

You can add a signal or a custom marker at the end of the timeline to listen to the event.
25games has amazing tutorials about this

Signal is simpler to use. You create signal asset, add a signal listener component, set reference to the signal asset and the function you want to call. Then add the signal to the timeline
For the marker, you’ll have to create a marker script, a listener that implements INotificationReceiver

@cdr9042 oooooh I knew about signals and how to use them, but they were lacking the flexibility I needed.

Markers are definitely extremely appealing here thanks for the tip

Very late to the game but I found the answer in this post