Free up memory from file menu pointers

* Cleanup sub-filemenu pointers after their results are copied.
* Cleanup file pointers after all operations have been performed on
the file.

Change-Id: Ie6c482c5ffddd7ebebdc99bbe8ae856e53e1405f
(cherry picked from commit 5360b52dba6b120b6e0ba5c775e2a961504a34a3)