@jkbbwr You are on the right track. To make your ZMQ operations cancellable then, you’ll need to detect cancellation and take an appropriate action (like closing a socket). You can do
coroutineContext.invokeOnCompletion { /* close socket */ }
inside your
run
function, so when it is cancelled, the socket is closed.