send SIGUSR1 or SIGUSR2 (depends on what exit code you want) to $YAD_PID from your functions

for example

function close_exit(){
    echo "close and exit"
    kill -s SUGUSR1 $YAD_PID
}
export -f close_exit

yad --text "simple dialog" --button="gtk-close:bash -c close_exit"