close window
add listener only when dom was ready