Link below provides a description from Redux Toolkit Query Documentation itself regarding how to reset the api state globally, where in your case after invoking logout
Link to the document :- https://redux-toolkit.js.org/rtk-query/api/created-api/api-slice-utils#resetapistate