Now, the application terminates when window is closed