Slow shutdown of application outside debugger

My application takes a few seconds to shutdown (debug or release) when started outside the debugger.
Looking at the task manager, the application seems to start releasing memory very slowy without using CPU then shuts down.
I don’t have this behaviour at all when starting the application from the debugger.

I run the application in 32 bit mode on Windows 7 64 bit.

Any clue ?

Probably the debug heap -

Well, my issue occurs when running my app outside the debugger. I had a look but it is related to the environment.
However my project is two years old so I may have forgotten to update some config stuff.