Added AddOnTerminate function

Added and slightly optimized the AddOnTerminate function to Simba.
Merge pull request #184 from idynin/master

Added AddOnTerminate function