Fix bug when close, the window have no response.

It will have a delay when close it.