Manage scaling down docker containers

Hello,
I have a question concerning a proper shutdown hook for docker container in the 1.12 api.
For example, let’s say we have 5 containers running an rpc server that replies to requests from clients; when scaling down to 4 containers via $docker service scale rpc=4 for instance, i want to be able to manage all the saved requests in the container and dispatch them or whatever. So what i of need a shutdown hook for docker containers when using the docker service API. Is this possible? Any suggestions or help would be really appreciated.

Thank you in advance.

Best regards,
Rudy