code: def clear_app_refs(self, gui=None):
          
          if gui is None:
              self.apps = {}
          elif gui in self.apps:
              del self.apps[gui]
docs: Clear IPython's internal reference to an application instance.
  
          Whenever we create an app for a user on qt4 or wx, we hold a
          reference to the app.  This is needed because in some cases bad things
          can happen if a user doesn't hold a reference themselves.  This
          method is provided to clear the references we are holding.
  
          Parameters
          ----------
          gui : None or str
              If None, clear all app references.  If ('wx', 'qt4') clear
              the app for that toolkit.  References are not held for gtk or tk
              as those toolkits don't have the notion of an app.