Any good OS should clean up all resources when the process exits; the 'always free what you allocated' principle is good for two things:
If your program leaks memory but never exits (daemons, servers, ...) continuously leaking memory will waste RAM badly.
You should not defer freeing all memory until your program terminates (like Firefox does sometimes - noticed how much time it takes for it to exit?) - the point is to minimalize the time for which you have allocated memory; even if your program continues to run, you should immediately free up allocated RAM after you are finished with it.