This method ends only when the window is closed, and the value passed to the Close method is returned.