on *:open:?:{ echo -s Query closed } works fine, but it only triggers if a query window is opened by an incoming message, not if your open one yourself. Make sure that the event is this only on *:open:?:{ in the script file, and that your remotes processing is on (/remote on).