If you wish to hide products when they are out of stock, go to Store -> Configuration and uncheck "Show Out of Stock Items".