Move destruction of the graph's filters to its own helper function.