Which malloc implementation do you use -- glibc, jemalloc or tcmalloc?
I have not noticed this, but I also don't look closely for the problem and my servers don't have more than 256G of RAM.
It would help to see a few stack traces or a CPU profile (perf record) from the slow shutdown. But I am not asking you to risk problems in production to collect them.
We don't talk much about the speed at which memory can be allocated from or returned to the OS. But with big memory servers it is something that needs more attention.
Long ago we might have made MySQL shutdown faster by skipping some of the code that free's memory. But in this case, the process was ending and it isn't clear whether you are restarting a process, or just restarting RocksDB within a process. While free'ing all memory is good for memory leak tests, it isn't that useful beyond that.
This blog post was inspired by our MySQL issue --
https://dom.as/2009/12/10/best-free-is-exit/