Check if a given text has all braces closed (in the correct order)