ask script to stop itself

	set ifile to "path:to:Desktop:Picture.png"
	set qifile to quoted form of (POSIX path of ifile)
	set cmd to "qlmanage -p " & qifile
	do shell script cmd
end try

the script does not exit itself unless i close the preview window. Please help me do it.
Secondly, is there a better way to close the preview window with the keyboard other than using “killall qlmanage”?

just found this:
When using the script, you can close the Quick Look window with the mouse (the conventional way), or close it in Terminal by getting the pid from the ps command and using kill pid#.

can anyone enlighten me more on how to use pid


if the script still runs, you can close the preview window with the ESC key.
To exit the script immediately use this

do shell script cmd & " > /dev/null 2>&1 &"

you are amazing ! million thanks for that :slight_smile:

gotcha: this behavior changes when the script is assigned a trigger because ESC key is not taken by the script and hence it does not exit