How to make an instance of a class nil?

I have a simple class called Barracks, it has hit points, attack, defense, etc. But whe its HP reaches zero, I want the instance to be nil, and the memory from all of that is freed up. How to do this?

instance = Barracks()

instance = nil

if instance.hp == 0 then instance = nil end

sorry had overlooked that you needed that condition

Ahh. Makes sense. Thanks