I think you sould use ConfirmationDialog node for this case, just right click and clik change node type. ConfirmationDialog will automatically hide/closing when you click on the cancel button or close button.
But, if you prefer to use your own modal, try using signal for each button. For example you have cancle_btn
node, and then use on_pressed()
signal. That will be generate function like this
func _on_cancle_btn_is_pressed():
pass
Replace pass
with
if get_node(your_modal).is_visible():
get_node(your_modal).hide()
Make sure your_modal
is parent of cancle button, apply button, and other modal stuff.