Yes you do have to return your post office box keys when closing your post office box.
If you rent a post office box from the post office and it has keys and you decide to close that post office box and move to another address then you need to return those keys.
If you don't return the keys to the post office box when closing the post office box you won't get your money back for the key.
Also the lock will be either re keyed or changed to a new lock.
So your key will be useless to open the box because the new person will need to know that they have the only key to the post office box other than the post office.
I have forgotten to return a key to the post office and nothing has happened to me.
But you should if you remember to return the key to the post office when you no longer need it.
Just go to the post office clerk and tell them you want to close your post office box and hand them the key and they will close the post office box for you.
You will also need to fill out a change of address form as well.