Debugging is a pain, especially when you get uninformative errors from the operating system. The following edited and partial answer demonstrates a generally useful technique when you are getting AV's in "bad" situations like after closing your app etc.:
The access violation dialog should say that an access violation happened at XXXXXX: read of address YYYYYY. Try running your program in the debugger. Pause the program and bring up the view CPU pane. In the upper left pane, right click and select Go To Address. Go to the address that caused the access violation. Look around a little bit and see if you can find where you are in the program.
Insert some breakpoints and try to close the program. When you hit a breakpoint, view the call stack and see if it gives any clues.