Detection when player stops using item

I've implemented right click detection following this tutorial: https://youtu.be/DPHtNXHVqUc And I have an advancement and a function that handle it (attached files)

Now, I would like to run a command specifically when the player releases the right click after holding it. How do I do that?

Continue to help post