Freeing resources, especialy memory, for relatively small applications at end of program never takes few minutes. It is typically less than second, or worst case maybe few seconds.

Something other than resource deallocation is wrong in your code if it really spends a lot of time shutting down (logging? threading?). Changing how you allocate memory may fix problem you are having, but most likely it will simply hide it because real problem will still be there. And crashes are relatively easy to debug, just attach debugger when it crashes and examine whats wrong.