I use Nisus Writer Pro, not Word, but…
This is something I do in NWP after compiling. I replace the page break before each new chapter or equivalent with a section break, then in the stylesheet, I set endnotes to be placed at the end of sections and to restart at 1.
As I don’t use Word or Libre Office, I can’t tell you how to accomplish it in those, but it must be possible.
HTH
Mark