Flask now terminates after the window is closed