Handle SIG TERM and INT to deregister

Also use *Var for flags so you don't have to dereference everywhere you
consume the flags.