I’m getting an error that says : uncaught exception: DeveloperError: This object was destroyed, i.e., destroy() was called.

In my code I am adding/deleting point billboards and adding/deleting czml files. I can add points and czml files. The error happens when I delete point billboard points and the try to re-add czml files. The code for my delete billboard points looks like:

function cleanup() {

new Button({
label : ‘Delete point billboards’,
onClick : function() {

I think the problem is with the getPrimitives.removeAll in the cleanup() function but I don’t know how to fix it. Any advice? Thanks