class_docstr: A base class containing for the 2D browser.
  
  This class contains all backend-independent attributes and methods.
class_docstr_tok: ["A","base","class","containing","for","the","2D","browser",".","This","class","contains","all","backend-independent","attributes","and","methods","."]
docstr: Handle close events (via keypress or window [x]).
docstr_tok: ["Handle","close","events","(","via","keypress","or","window","[","x","]",")","."]
code: def _close(self, event):
      """Handle close events (via keypress or window [x])."""
      from matplotlib.pyplot import close
  
      logger.debug(f"Closing {self.mne.instance_type} browser...")
      # write out bad epochs (after converting epoch numbers to indices)
      if self.mne.instance_type == "epochs":
          bad_ixs = np.isin(
              self.mne.inst.selection, self.mne.bad_epochs
          ).nonzero()[0]
          self.mne.inst.drop(bad_ixs)
          logger.info(
              "The following epochs were marked as bad "
              "and are dropped:\n"
              f"{self.mne.bad_epochs}"
          )
      # write bad channels back to instance (don't do this for proj;
      # proj checkboxes are for viz only and shouldn't modify the instance)
      if self.mne.instance_type in ("raw", "epochs"):
          self.mne.inst.info["bads"] = self.mne.info["bads"]
          logger.info(
              f"Channels marked as bad:\n"
              f"{self.mne.info['bads'] or 'none'}"
          )
      # ICA excludes
      elif self.mne.instance_type == "ica":
          self.mne.ica.exclude = [
              self.mne.ica._ica_names.index(ch)
              for ch in self.mne.info["bads"]
          ]
      # write window size to config
      str_size = ",".join([str(i) for i in self._get_size()])
      set_config("MNE_BROWSE_RAW_SIZE", str_size, set_env=False)
      # Clean up child figures (don't pop(), child figs remove themselves)
      while len(self.mne.child_figs):
          fig = self.mne.child_figs[-1]
          close(fig)
          self._close_event(fig)
  
imports: import importlib
  from abc import ABC, abstractmethod
  from collections import OrderedDict
  from contextlib import contextmanager
  from copy import deepcopy
  from itertools import cycle
  import numpy
  from .._fiff.pick import _DATA_CH_TYPES_SPLIT
  from ..defaults import _handle_default
  from ..filter import _iir_filter, _overlap_add_filter
  from ..fixes import _compare_version
  from ..utils import _check_option, _get_stim_channel, _validate_type, get_config, logger, set_config, verbose
  from .backends._utils import VALID_BROWSE_BACKENDS
  from .utils import _get_color_list, _setup_plot_projector, _show_browser
label_desc: Use image node_id 18 for calling the BrowserBase obj's underlying member method code with example usage: obj._close(event) without return types