It can be used to prosecute you if they so desire
I've never even heard of someone doing this. I know people sometimes want samples of their code from past jobs to show future employers, but even that I would explicitly ask about when leaving, and I certainly wouldn't ask for the entire codebase on anything large or meaningful.
Hell... I don't think I'd even want a copy in most cases, it seems like it'd open me up to legal and privacy risks without any actual benefit.
Great way to get sued. That's going to be logged. Isn't this what got Levandowski in trouble when leaving Google?
I definitely do not do this. In fact, once you stop paying me, I don't care about your code in anymore. It goes in the trash. It's not my problem after that.