Professor says he won't report my cheating if I admit it in writing. Is it a trap?
You betrayed your professor with this cheating behavior and lost his trust. But trust from others is the most important value in academia and in science. It is a necessary, but not sufficient, condition for any kind of research in any scientific domain. It is necessary for any homework (the goal of any homework is just transmission of skills and of knowledge, nothing else; correcting and grading home-works is the worst part of any teaching job). And when you read any research paper, you have to trust its author. If you cannot, the author committed academic dishonesty. Unethical behavior is the number-one enemy of science.

Your professor is responding by asking you some email (that is some formal confession). He is likely to not use it now but could use that later.

I would have behaved as he did. He is giving you a last chance. Be grateful to him!

We all make mistakes, but you should try hard to avoid repeating yours. Errare humanum est

Your past behavior (described in your question) was unethical, not an adult one and incompatible with any PhD studies. 

Most of us cheated at least once in our studies. My best teachers in French high school (collège) told me: "don't try to cheat, at your age, I cheated more than you can now". And I'll be 60 years old in August 2019.


  I am thinking about just withdraw my PhD right know before his complain gets to the dean. 


Doing a PhD is hard work, and you'll make a lot of mistakes. They are part of the job (and that is why I like so much the "Philosophical degree" in US academia: in France I am just a "Doctor" of computer science, but the only thing I really know is that I know almost nothing; read more on the etymology of the Doctor word).

NB: I am not a native English speaker, since I am French. During my own PhD I did pay for professional help from a psychotherapist, and as a human being (probably as old as your own father), I believe you should do likewise, at least to increase your soft skills and probably to be able to achieve your PhD. It is a really hard journey.

I welcome any private email about this question (cited by its URL) and my answer above if it is written in French by a non-French native speaker.