in reply to how to automatically kill a program by itself?

You don't identify the type of script - if it were sh/ksh i.e. a half decent shell :-), I'd let the OS do the work ... something like
at now + 2 hours "kill $$"

A user level that continues to overstate my experience :-))