How can I select the specified number of branch line?

I want to make player can close the dialogue box (or just hide it) if the dialogue is over.
So I want to find the number of the end of dialogue line(automatically or by myself).
But I can’t find the useful expressions from “DialogueTree”.

Can someone help me?