One possible way you could do this is build a request handler on something like /logout. The /logout request handler would first log the user out using the code that i provided and then would respond in the html response by directing the user to the logged out page.
So in Mendix you would use a link button that would point to ./logout. To make sure that they are directed to the correct html page you could include some get parameters for example ./logout?page=logoutpage1.html.
If your pages are in Mendix and not html you need to Log the user out using a java action inside a microflow then open a page in the microflow. However this probably won't work because you will need to get a new session for anonymous users. So you should probably redirect the user using a redirect page and a deeplink. You could make the redirect dynamic based on an attribute from a object.
There is multiple options depending on what you are trying to achieve, whether the page is hosted in Mendix or external.
Create custom logout button? Use the logout java action, introduce anonymous users and create pages where you want them to go