Add types for lifecycle events.

Rather than a separate handler for "failure", I think we should pass a termination reason to the hook -- a number of reasons, including client-provided reasons are enumerated in #137.