Updated HtmlClosingParser to throw custom errors when encountering
unexpected state.