I have used this code and it works fine.
on ^*:CLOSE:@:$iif($target == @mywindow, myalias)
I suspect that custom windows are the exception to the ^ prefix not working with the CLOSE event.
However, while I don't have a v6.31 installed, I couldn't find anything in
versions.txt that would indicate that we can now use $input inside an event.
Try aliasing out the bulk of the event and just calling the alias from the event.