Fixed Bug where closing popup windows would terminate app