Fix a bug in the finalizer.