add shutdown hooks