Ok… here’s a detailed breakdown… it’s really very simple.
Here’s how you do it for the expiry date:
First, make sure your database is set up correctly, with at least the following fields on your Listing Datatype:

Next, set up a backend workflow with a single parameter of ‘Listing’, and a single action to change that listing’s publication status to ‘No’
Then, wherever it is you create your listing, just add an action to schedule that workflow to run on the expiry date of the listing:
That’s all there is to it.
If you want to do it when the stock count hits 0, you can just use a database trigger event as shown below (although you could argue there’s really no need for that… just use search constraints on your listing pages to exclude Listings with a stock count of 0).
In any case, here’s all you need to do:
Set up a database trigger event on the backend, as shown below:
Then in that trigger event, just schedule the ‘Unpublish Listing’ workflow:
It’s that simple.