How can I close the opened window page from in Tornado.

I would like to be able to close the page based on the lastClick variable.

Something like

if gd.get.lastClick = "applyadd" then
window.close()
endif

This gives me a compilation error because it does not recognizes the window variable.