Cleanup code using the Garbage Collector (GC) would look like this:
Usually Word would clean up (with some delay) when all references are properly cleared, but if you want to force the cleanup (still after making sure all references are cleared) would be with the code above.
It looks kinda strange but if you want to know the ins-outs go find the book by Andrew Whitechapel (former Office PM) https://www.amazon.com/Microsoft%C2%AE-Development-Microsoft-Developer-Reference/dp/0735621322 in Chapter two, from the top of my head.
You will have to use Office automation for this.
Read this article as a starting point. Follow the links on that page for more information.
You may also want to purchase (any of) these books: