code: def do_shutdown(self, restart):
          
          print("in shutdown function")
          if self.hist_file:
              with open(self.hist_file, 'wb') as fid:
                  data = '\n'.join(self.hist_cache[-self.max_hist_cache:])
                  fid.write(data.encode('utf-8'))
          if self.mva:
              self.mva._endsas()
              self.mva = None
          if restart:
              self.Print("Restarting kernel...")
              self.reload_magics()
              self.restart_kernel()
              self.Print("Done!")
          return {'status': 'ok', 'restart': restart}
docs: Shut down the app gracefully, saving history.