Finalizer implementation