@JF ******
there are a few options if you'll actually run out a day early.
1) depending on your flight time, you can try checking in early and crossing through passport control before midnight
2) you can go 2-3 days before your extension expires and see if they'll accept an extension application that you don't qualify for. If they accept the application, they'll give you a 7-day "extension denied" stamp starting from the day of application.
3) overstay one day. There's no fine for one day overstay if leaving from an airport.