opt: Add a function to free the internal memory.