Hi @Mata Ricardo,
Thank you for posting in this community.
Unfortunately, PowerShell doesn't seem to be able to close Excel files automatically. Perhaps you could try using Power Automate to create streams to close Excel automatically. It provides a way to close Excel.
Reference: Close Excel.
Since our team is mainly responsible for SharePoint related issues, we are missing information related to Power Automate. If you have a related question, visit this Power Automate Community and ask your question.
Thank you for your kind understanding.
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.