Hello,
What version and license of phpdocx are you using?
Please note that DOCX documents don't work internally with pages but with sections. Sections and contents generate pages. A DOCX is 'painted' dynamically, for this reason the output of a DOCX my change depending on the DOCX reader.
MS Word doesn't include a last page target for headers or footers, only first, default and even targets are available. Using an Advanced or a Premium licenses, you can generate a new section at the end of the document with addSection (https://www.phpdocx.com/api-documentation/layout-and-general/add-section-Word-document-with-PHP) and insert a new footer into this new section with addFooterSection (https://www.phpdocx.com/api-documentation/layout-and-general/insert-footers-section-Word-document-with-PHP).
Regards.