Update and probable cause identified
A power failure does not keep files open after a restart.
Yes, I agree but a power failure followed by restart does cause (sometimes) damage to the log file created by the inverter monitoring program (Aurora Communicator, provided by the inverter manufacturer) thus extra initialisation lines may appear in the log file in an unusual order. My code attempts to anticipate and handle this kind of event.
While reviewing my code and debug log file following another program freeze of the same kind I did find that in one of my procedures I had unintentionally omitted code in the Exception that would have logged an exception.
On both of the "freeze" I ah seen from the macOS Activity monitor that there was a single data file involved. I have concluded that there was some issue with that file (and my code) that had caused an exception. That exception had been caught by the Try - Except and the program execution continued WITHOUT any message being output and the file not being closed. This had then repeated until open file limit exceeded and program freeze.
Thank you all for your observations, comments and suggestions. I will mark this thread as solved.