Using \AtEndDocument produces a new page with the class exam, if not put before \documentclass{exam}.
I made a package that modifies some key elements of the class, but the package needs to write something at the end of the document to work properly. To be precise, it uses \glsaddallunused from the glossaries package.
I've read on this very site that using \RequirePackage should work before \documentclass, but even using \RequirePackage to load the packages I use in my package, it yields a bunch of errors (including about some xkeyval package loaded before \documentclass):
Package xkeyval Error: xkeyval loaded before \documentclass. ...keyval loaded before \protect\documentclass}
How can I circumvent this to add stuff on what should have been the last page of my exam file?