The goal of the code is to launch ffmpeg to resize and encode a video and be able to close it using yad. I found the solution by storing the PID of the process in a temporary file. I spent long time trying to use single quotes inside bash -c 'command'. I finally solved it by replacing single quotes with '"'"'
export TMP="$(mktemp)"
yad --notification --no-middle --command="" --image=emblem-warning --menu='Cancel current job ! bash -c "kill $(cat $TMP); rm $TMP;"' & pid=$!
export fname="video.mp4"
bash -c 'echo $$>$TMP; exec ffmpeg -n -loglevel warning -i "$fname" -acodec copy -vcodec libx264 -crf 24 -vf "scale='"'"'if(gte(iw,ih),-1,720)'"'"':'"'"'if(gte(iw,ih),720,-1)'"'"'" "${fname%%.*}_720.${fname##*.}"'
kill $pid