fix finalizer in RESTGateway