Revert "stop using gate and use finalizer instead"

This reverts commit ddf06e1c5965a93083391b9c3d9df8a70f5af35e.