I just wrote a code in C++ which does some string manipulation, but when I ran valgrind over, it shows some possible memory leaks. Debugging the code to granular level I wrote a
At the time your process is actually exiting, as when main() exits, the OS will reclaim all resources allocated to your application either way. How you exit isn't so important - at least with regard to dynamic memory.
If you have some distributed database connection open or something, you should use atexit() handlers to close it, and forceful termination with straight-up exit may make them not run which would be bad - but as far as your OS resources are concerned you're probably okay.
You should also always make sure you release (manual) file locks and similar things as they may not go away due to a process exit.