Finish the heartbeat handler and the end handler.