According to the Special Act, persons who are covered by it but have applied for international protection may withdraw their application and will be able to stay legally in Poland for 18 months and have access to all benefits. How do I withdraw my asylum application and can it be withdrawn at any time?

The Act of 12 March 2022 on assistance to Ukrainian citizens in connection with an armed conflict in the territory of that country provides for the possibility of changing the decision (resignation) regarding applying for international protection (refugee status, subsidiary protection).
Pursuant to Article 2 clause 5 of the special act upon withdrawal by the citizen of Ukraine:
an application for international protection or an application on behalf of which such applications have been submitted, a declaration of intention to submit applications for international protection in the Republic of Poland or to which such declarations of intent concern, art. 2 clause 1 of the act. A person who has submitted a resignation from applying for international protection may take advantage of various opportunities, including benefits provided for in the special act.

How to do this correctly?
Pursuant to Art. 14 § 1d of the Code of Administrative Procedure, letters addressed to public administration bodies may be made in fixed writing in paper or electronic form. Applications (requests, explanations, appeals, complaints) must be submitted in writing, by fax or orally for the record. Applications recorded in electronic form shall be submitted to the address for electronic delivery. The application should contain at least the indication of the person from whom it comes, its address, also in the case of submitting the application in electronic form, and the request and meet other requirements set out in specific provisions. First of all, it should be noted that the application brought in writing or orally for the record should be signed by the applicant, and the protocol, moreover, by the employee who prepared it. When the application is submitted by a person who cannot or is unable to sign, the application or report is signed by another person authorized by him, making a note about it next to the signature. Letter informing the Head of the Office for Foreigners about withdrawing the application or declaration of applying for refugee status (subsidiary protection), should be submitted in person or sent to the correspondence address of the office: ul. Taborowa 33, 02-699 Warsaw. Electronic inbox: /UDSC/SkrytkaESP.

The legislator does not specify until when the resignation from applying for international protection should take place. The cut-off date is certainly the completion of the proceedings (issuance of a decision) on granting international protection. It is worth remembering that the person against whom the international protection procedure is pending cannot use the facilities and benefits resulting from the special act (e.g. he / she cannot conduct business activity).
It is worth emphasizing that, in accordance with the content of the Special Act, the registration of a Ukrainian citizen’s stay on the territory of the Republic of Poland takes place at his request. The application in question should be submitted no later than 30 days from the date of entry into the territory of the Republic of Poland (in fact, it is an application for a PESEL UKR number). It would therefore be best to give up applying for international protection immediately.