code: public void setOnCloseListener(@NonNull final android.support.v7.widget.SearchView.OnCloseListener listener) {
          if (searchView != null) {
              searchView.setOnCloseListener(new SearchView.OnCloseListener() {
                  @Override public boolean onClose() {
                      return listener.onClose();
                  }
              });
          } else if (supportView != null) {
              supportView.setOnCloseListener(listener);
          } else {
              throw new IllegalStateException(ERROR_NO_SEARCHVIEW);
          }
      }
docs: Sets a listener to inform when the user closes the SearchView.
  
  @param listener the listener to call when the user closes the SearchView.