code: def cleanup():
      
      temp_dirs = []
      for key in ('headless', 'headed'):
          if FIREFOX_INSTANCE[key] is not None:
              if FIREFOX_INSTANCE[key].profile:
                  temp_dirs.append(FIREFOX_INSTANCE[key].profile.profile_dir)
              try:
                  FIREFOX_INSTANCE[key].quit()
                  FIREFOX_INSTANCE[key] = None
              except:
                  logger.exception(
                      "Exception occurred in browser cleanup"
                  )
      for temp_dir in temp_dirs:
          shutil.rmtree(temp_dir, ignore_errors=True)
docs: Must be called before exit