add terminate/codechange and gen_event exist msg handling