managing the exit of the gui