as of last October, non-residents need to buy a 30 dinar ($15) exit stamp before proceeding through passport control when leaving Tunisia. supposedly they sell it at hotels and banks throughout the country, but since i was staying at an Airbnb i just waited until i got to the airport. it’s a teeny postage-stamp sized thing that you affix by wetting the back (like a real postage stamp, though i fear many millennials these days don’t know how to work one). i’ve heard it’s best to let the passport person do it for you, as they are supposed to stamp over it and it should go next to your entry stamp. just be careful you don’t lose it along the way!
at Tunis-Carthage International airport, there are a row of banks opposite the entryway to Departures. any of those will sell you the stamp. you can buy it at any time as long as you have it before you enter the departures area. i can imagine that lines can get long during the high season so if you can get it elsewhere (“hotels, travel agencies, finance offices, customs offices (including the borders ones), banks and tobacco shops”) during your travels, it’s probably best to do that.
i’ve read rumors that there are people who will try to sell you these stamps at an inflated price — do NOT pay more than 30 dinars for it. the price is printed on the stamp.