Which is to say oil wells don't shutdown when the profit goes negative because that never happens. Oil wells do shutdown (or more likely produce less because the pump is slowed) if the owner decides they want to control supply to bring the price up - but you have to have a lot of wells to even think about that. During the pandemic oil wells shutdown, but that was because there was no place to put store the oil - if you could store it there was plenty of value in pumping it (though it was an investment).
Refineries don't shutdown when the profit goes negative. Again, because the sunk cost in machinery is a large part of the cost. If the profit goes down they will often not remodel and eventually shutdown because the equipment it wore out. Many have shutdown because the right crude wasn't available (and they didn't want to invest in machinery to handle crude they can get) - and then reopened a decade later when someone started pumping the right crude again.
Yes of course if profit goes negative they will both shutdown. However long before profits go negative they will be managing things and so in practice they are shutdown for other reasons first.