最中に => while; during; in the middle of ~ N3
を契機に => as a good opportunity/chance to N2
Expected
を[機「き」]に => Use A as an opportunity N1
Time, Situation
〜がさいご(が最後) => if you do... negative result N1
Decisive (resolute decision)
[最中「さいちゅう」] => In the middle of A N3
Time, Situation
たが[最後「さいご」] => Once A occurs, B happens N1
Information, Report
を[契機「けいき」] => As a good opportunity A, (do) B N2
Information, Report
をきっかけに/を契機に => with… as a start; as a result of; taking advantage of N2