implement the function that close window