You should not have to repay VAT on goods purchased for resale given that they are in fact sold. If at the end of trading they cannot be sold I would view them like spoilage. They were bought with the intention to resell there should be no issue of repaying the VAT.
The issue of machinery may be more complicated. If you sold the machinery id advance of ceasing to trade and charged VAT on the sale, I believe that would be a correct treatment.
While professional advice might be needed, it might cost more that the potential VAT involved.
You might get more detailed advice on here, but you have provided very sparse details.