I can't find any issues with 'end_document' but I discovered that 'start_document' didn't fire for empty documents and could even fire multiple times if parse() was called repeatedly with empty chunks. I've now uploaded HTML-Parser-3.52 which make sure 'start_document' fire exactly once per document.
--Gisle