classdef myClass_cleanup < handle
  properties
    cleanup;
  end

    methods
        function obj = myClass_cleanup()
          obj.cleanup = onCleanup(@()delete(obj));
        end
    
        function delete(obj)
        disp('delete was called');
        end
    end
end