N1
を機に
をきに
Opportunity, Occasion
妻の妊娠を機にタバコを止めることにした。
I decided to quit smoking when my wife became pregnant.
Explanation
「Nを機に」 means 'taking N as an opportunity'. An important moment in life or society (graduation, marriage, a birth, recovery, retirement, an anniversary) becomes the turning point for a new way of life or a big change: 「妻の妊娠を機に、タバコを完全にやめた」 (When my wife became pregnant, I quit smoking completely), 「定年退職を機として、田舎へ移住した」 (After retiring, he moved to the countryside). What follows is mostly a major decision the person makes on purpose, not a passing impulse. 「を機として」 also works; before a noun use 「〜を機にした+noun」.
Mixed up with
「〜を機に」: elegant and written; treats the event as a great chance and the start of a new chapter.
「〜を契機に」: the most formal and official; common in political or economic commentary and big reforms, e.g. using a system reform as the turning point.
「〜をきっかけに」: from speech to general use; even a tiny everyday coincidence will do, e.g. starting Japanese after happening to watch an anime. Such small things don't suit the weighty 「を機に」.