How to mail the editor asking to withdraw my submission?
Until you give up copyright to your work it is yours. Yes, you can withdraw it. However, you might be better served by sending a note that you have found a flaw and expect to have a revision of the paper within X days, where X is reasonably small. Ask how to proceed and ask if the editor can just put the paper on hold for the interim. 

I can't predict the response, but it might be better than withdrawing it altogether. But, yes, you can do that. 

Adding the colleague as a co-author should also offer no difficulties.