Tweaking a bit more.
exiting the run thread after the window is closed.