Bugfix/max booleans

When max boolean clauses are reached the token stream is left back in an invalid state, as close is not called. Fixing the issue with RAII.