I would usually wait for formal acknowledgement - such as if they write an email back, like you mentioned.
Some journals where they have a website for submissions, I can withdraw it there so it is clearly shown.
I commend you for not making the same mistake as some other people have mentioned to submit to multiple journals - and then they had the mess after when it was accepted or published in both journals.
Thanks Josef for your answer. In my condition the journal have website and it neglected replaying back to my email for months. Is it logic to wait? What if they never replayed?
If you submitted the paper via the journal's website, then as Joseph C Lee mentioned, you could perhaps withdraw the paper via the website. Many journals also make provision for you to send messages to the editors via the website. so that is another option.
However, if the two options above are not available, then I suggest that you send several emails (to the email address listed on the website or in the author guidelines, but if there are multiple email addresses, then send to all of these) at intervals of a week. Then, after a month, if you have still not received a response, I believe that you have paid your dues and can submit elsewhere.
If, then journal then later responds via feedback on your paper, you can then simply state that you have withdrawn the paper, as per the prior emails that you sent them and include these as evidence.
That is terrible by them. I can understand it makes it an even more terrible situation for you. If they do not answer email for you, are there any other ways shown on the journal's website to contact them?
If there are no options, then I think the approach mentioned by Rodney Duffett is very good: keep emailing them every week until they reply and you can also use that as evidence if you need it later.