bug in key_close causing over-deletion