Add resource closing to PrologEnvironment

Adds close() to PrologEnvironment that runs all the necessary routines
to close any resources when the environment is no longer needed.
When computing a resource to store that needs to be closed later, add
a cleanup routine using addToCleanup(). Adds the Repository
stored value as an example. Refactors ChangeControl to have the
environments clean up after themselves.

Change-Id: I5d109be40cb9212068624820999d522e71ef6fd6
3 files changed