Things are getting better, but I have a couple of niggles if anyone can help :-)
1) I tried the Keypress addition to stop the script, as mentioned by Kirsle:
$mw->bind ("<Motion>", \&close);
$mw->bind ("<ButtonPress>", \&close); # mouse clicks
$mw->bind ('<KeyPress-Escape>', \&close)...