Fix cascading failure when opening graphs

* Lexer state needs to be flushed on failure to open.