Currently when we are closing we are not checking if loading or page rendering in progress. Also pdfDocument.destroy is a async operation.
We should either wait for all operations (fonts are cleared, the loading and rendering operations) to complete or ensure all started operations are aborted and those will not have further effect on the viewer.