Any modern OS will manage it and clean up the whole memory that allocated by a process after closing it
Don't worry about that. You must worry about the memory when your program is running.
When your code is running. Avoid using bare pointers, try to use smart pointers if you need pointers.