This Docker image will catch the SIGTERM signal and then take STOP_TIMEOUT seconds to cleanup.
$ # Build the Docker image.
$ docker build -t slow-stop .
$ # Run the container, when the SIGTERM is received spend 10 seconds doing "cleanup".
$ docker run -dit -e STOP_TIMEOUT=10 -p 8000:8000 slow-stop:latest