Check if key exists before deleting it.