Is the user you're logging out a named user or an anonymous user? Because when you logout your user, they shouldn't become anonymous but really logged out:
Core.logout(getContext().getSession());
Did you see the user becoming anonymous for example in the database?
I have a similar issue. Users connecting to the application are initially taken to an anonymous access Launchpad page by using the Alternative Home Pages mechanism under Navigation. The Launchpad screen contains some system announcements etc. and the Login Form widget to allow them to log in as a registered user.
When they are on the Launchpad page, anonymous users are consuming a license.
When logged-in users are logged out of the application, they are returned to the Launchpad page by the same Alternative Home Page mechanism, so the user becomes an anonymous user and the license token is still consumed, which is the situation that you describe, Peter.
To overcome this, I also have the microflow timer widget on the Launchpad form. This is set to run after a few minutes. The microflow that is triggered opens a form in content which contains the URLRedirector widget which redirects to an external web page. This then releases the anonymous user license token within about 3 minutes.
So, pretty much the same as you describe - just the redirect takes place after a few minutes so that users arriving at the Launchpad form to access the application do not immediately get redirected!