CFY-644 refactoring terminated task handling so non graph tasks can share common code