The procedure for getting extra time in the US is different depending on whether you entered under a B visa or under the visa waiver program (VWP).
Most European visitors will have used the VWP. In that case, there is a regulatory provision for an extension of up to 30 days called "satisfactory departure" (8 CFR 217.3(a)):
§ 217.3 Maintenance of status.
(a) Satisfactory departure. If an emergency prevents an alien admitted under this part from departing from the United States within his or her period of authorized stay, the district director having jurisdiction over the place of the alien's temporary stay may, in his or her discretion, grant a period of satisfactory departure not to exceed 30 days. If departure is accomplished during that period, the alien is to be regarded as having satisfactorily accomplished the visit without overstaying the allotted time.
However, it is not at all obvious how one would apply for satisfactory departure. There is no information about this on the main USCIS website, and the USCIS appointment system website says
If you are inside the United States, you can no longer schedule an appointment online using InfoPass for domestic offices.
(See below in the comments for a report from Crazydre that USCIS is referring people in this situation to CBP deferred inspection centers.)
Even if you could manage a 30-day extension under satisfactory departure, it won't help if you are required to remain in the US for more than 30 days beyond the expiration of your allowed period of stay.
Visitors with B visas may apply to extend their stay. Note that the relevant date is the I-94 date, not the visa expiration date. The application is somewhat costly ($370 plus $85 for biometric services), and may not be decided before you actually leave, but filing the application before the expiration of the admission period shown on the I-94 will protect you against various negative consequences of overstaying. It also demonstrates good faith.
If you do not know your I-94 expiration date, you may look it up at https://i94.cbp.dhs.gov.
Yesterday, I noted in a comment (on an answer that has since been deleted) that it might be easier to get to Canada or another country to avoid overstaying in the US. You have now edited the question to note that you intend to do just that. In that case, then, it might be useful to note that it is legally permissible for you to reenter the US quite soon after leaving, although that is subject to the discretion of the officer at the border, and the likelihood of being permitted to do so will probably be fairly small if you've just been in the US for close to 90 days (VWP) or six months (B visa).
Furthermore, there is confusion (even among government officers) about the conditions concerning "short trips" to adjacent countries by VWP visitors, so returning to the US may be more difficult for VWP visitors in this position. Such a person might be able to get a B visa while in Canada if necessary.