Petition for Withdrawal
In order to withdraw a patent application, you must file a petition with the U.S. Patent and Trademark Office. The petition is filed in accordance with 37 CFR §1.313, the federal statute governing patent withdrawals. In the language of patent law, you are asking for a "withdrawal from issue," and must show good cause why the withdrawal is necessary. At the time of publication, the filing fee for the petition is $130. The USPTO generally grants these petitions unless you have already paid the issue fee, in which case another procedure is involved.
If you've already paid the issue fee, the USPTO will not allow you to withdraw the patent, unless you meet certain conditions. The claim must be "unpatentable," meaning it won't meet the guidelines for issuance and you must file a statement or brief explaining your reasoning. Or, you may withdraw pending your request for continued examination by the USPTO, meaning the application has been denied or is under appeal. Finally, an applicant may withdraw by an express abandonment.
An express abandonment means filing a different petition (Form PTO/SB/24, Express Abandonment) in which you state your desire to drop the application completely, with no intention of filing amendments, appeals or otherwise pursuing the matter. You may request a refund of certain fees charged by the USPTO, including the search fee. If you wish to avoid publication of your application, you must file a form that specifically requests that (Form PTO/SB/24A, Petition for Express Abandonment to Avoid Publication).
Normally the USPTO publishes a patent application 18 months after you submit the first document to open the case. If you succeed in withdrawing the patent before publication, the "Pre-Grant Publication" application number survives, but the USPTO will publish no documents in connection with the application. Before publication, the agency keeps the application itself, as well as any designs or documents you've submitted, confidential.