Add startup and shutdown hooks.