Add shutdown hook for graph