Related to #3551
Currently /gateways/delete API endpoint terminates gateways synchronously. It locks gateways for a potentially long time and may be slow to respond. The endpoint should only mark gateways as terminating, and the termination should be done in background. This should be done before moving gateway processing to pipelines (#3551).