add runtime hook to properly shutdown graph resources on emergency exit