Release memory on exit (leak detected by cppcheck)

Free memory on exit to avoid leaking.

I've launched cppcheck on mozilla-central. It's still running, but I have some results.