         }
     }
     
+    func remove(_ instance: Kinieta) {
+        if let index = instances.index(where: { $0 === instance }) {
+            instances.remove(at: index)
+        }
+        
+        if instances.count == 0 {
+            displayLink?.invalidate()
+            displayLink = nil
+        }
+    }
+    
     @objc func update(_ displayLink: CADisplayLink) {
         
         for instance in instances {
-            let frame = Frame(timestamp: displayLink.timestamp, duration: displayLink.duration)
-            instance.update(frame)
+            let frame = KinietaEngine.Frame(displayLink.timestamp, displayLink.duration)
+            let finished = instance.update(frame)
+            if finished {
+                self.remove(instance)
+            }
         }
     }
     

import UIKit


struct Frame {
    var timestamp: Double
    var duration: Double
}

class KinietaEngine {
    
    static let shared = KinietaEngine()
    

    var transformations = [Transformation]()
    
    
    @discardableResult func update(_ frame: KinietaEngine.Frame) -> Bool {
        
        return false
    }
    
    // MARK: API
