Added closeWindow function to JS