My paper got accepted in a mediocre open access journal. However later I found out that its publishing fees was too high.
What would be the correct way of asking a withdrawal of your article from the journal?
If it has been accepted but you have not yet signed any sort of agreement, then it's easy in theory: you just tell the editor that you have decided to withdraw the paper. They might be unhappy, but you have a right to do this (both legally and according to academic norms).
If the paper has already been published, then there may not be anything you can do. Retracting a published paper is serious business, done only in cases of serious error or unethical behavior.
If you have already agreed to some sort of license allowing publication and paid (or agreed to pay) but the paper has not yet been published, then you should move fast. Legally the journal can go ahead and publish, and they may decide to do so, but your chances of convincing them before they publish the paper are higher than after they publish it.
There have been stories of unethical journals publishing papers that have been withdrawn and then demanding money. If that happens, then it is serious misbehavior on the part of the journal (and proves you were wise to withdraw the paper).