Fixed AddOnTerminate and added DeleteOnTerminate

Also added $DEFINE PS_ADDONTERMINATE to detect its definition in external scripts and includes.