Add a windows listener to frame.

When the window is closing, send the close request to server, then close
the local socket