cuda: add finalizer to clean up allocated memory on GC