Fixed AddOnTerminate and added DeleteOnTerminate

Also added $DEFINE PS_ADDONTERMINATE to detect its definition in external scripts and includes.
Merge pull request #186 from idynin/master

Fixed AddOnTerminate and added DeleteOnTerminate