With inventory sync turned on (Pro plan and above), the gift rule pauses automatically as soon as the gift product is out of stock.
This happens not only when an order with the gift sells the last one, but also when you set the inventory to 0 in the admin or when other orders sell it out.
When the gift is back in stock, a rule paused for being out of stock resumes automatically. You can also resume it yourself with the Active switch in the list.

Steps
- In the gift rule editor, under Inventory, turn on Pause this gift rule automatically when the gift is out of stock (and resume it when the gift is back in stock).
- Select Save.
Inventory sync works only when Track quantity is turned on for the gift product.
Related
Pause gifts by quantity and inventory