Unless you are leaving on less than ideal terms, I'd think you could draw up a simple statement indicating X was purchased under your license, lot #... and it has been retained by the practice signed by you and a responsible party (doc or practice manager). Not a fail safe, but an understanding of possession. If they aren't reasonable, you could claim they stole it.
Just a couple years ago, an employee stole my partner's Rx pad with DEA number/triplicate. He was writing #60 oxy for himself q5 days. It went on almost a year until a different pharmacist was filling in, who called the office to confirm the rx. It got weird real quick. I don't think he was using much (or any) of it, but no felony for sale/distribution/etc.
The doc could tell it wasn't his signature, but it otherwise looked just like a normal rx (ignoring the q5 day pattern in perpetuity.)