Turns out it was indeed a bug. After the last item was sold, the stock immediately went from 3 to 0, and the listing automatically switched to inactive as usual. Not sure how often this happens, but I guess if you have the same problem, then just wait until it sells all the stock and it should be fine. The only issue is keeping track of your inventory will potentially be confusing.