code: def close_tab(self):
          
          if len(self.tab_pages) > 1:  # Cannot close last tab.
              del self.tab_pages[self.active_tab_index]
              self.active_tab_index = max(0, self.active_tab_index - 1)
  
          # Clean up buffers.
          self._auto_close_new_empty_buffers()
docs: Close active tab.