I have implemented this logic to logout customer after registration, Its only working before logging in a new user.
After clearing cache and when I register a user it logout the user and for second third ... it works perferct, If I login a user and come back and create a new user it's not working it takes me to home page.
If I clear cache again it works. Not sure why its happening.