Citing Mathematical Proofs given on Math Stack Exchange
There are actually two questions on MathOverflow that ask how to cite answers found on MathOverflow. I would recommend following their advice.

One of them is a fairly old question, whose answer is somewhat outdated. Summarizing:


Even though you may not be legally obligated to show where you got your answer (for example, when MO points you to a theorem already in the literature), it is a good idea — it never hurts to be generous and honest. (And if you're copying part of an answer, not citing it would be plagiarism.)
There is a little button for each answer that says "cite" and will give you a citation. You might have to reformat this to make it fit in your journal's bibliography style.