The window closes, because the program is finished.
If you simply add time.sleep(5)
at the end (with the according import of time), the window will stay open for five seconds.
Otherwise, you could probably build a while(True) loop which ends on the condition, that the button for window closing is pressed.