Do you want to continue selling when out of stock?
If not, go to the product page in Shopify and scroll down to the Inventory section, make sure "Continue selling when out of stock" is unselected.
At checkout screen, Shopify will then prevent a customer from buying when the product is out of stock (or not having enough inventory).
There are some oversell situations. Please refer the Article Is there any chance of overselling a connected product for more details.