Fix crash when clicking close or pressing Ctrl-W without tab.