You can delete pages in PDF files using removePagesPdf (https://www.phpdocx.com/api-documentation/docxutilities/remove-pages-pdf-document-with-PHP).
DOCX documents don't work as PDF documents; in a DOCX document the contents are 'painted' (displayed) dynamically. DOCX documents work with sections that include contents that generate pages (for this reason the exact output of a DOCX depends on the program used to open it).
Using phpdocx you can remove contents in a DOCX using removeWordContent (https://www.phpdocx.com/api-documentation/docx-path/remove-elements-in-docx). With removeWordContent you can remove all contents of the last page knowing which contents you need/want to remove (including the section tag if needed to avoid generating the blank page).
If you send to contact[at]phpdocx.com a DOCX sample we'll generate and send a sample script to illustrate how to remove the contents of its last page using phpdocx (so the last page won't appear).