"Article 40.13 of the Formula 1 sporting regulation states: "If the race ends while the safety car is deployed it will enter the pit lane at the end of the last lap and the cars will take the chequered flag as normal without overtaking.""
The race didn't end with the safety car deployed. The safety car came in before the end of the last lap not "at the end of the last lap".
Shame cos it was a great opportunistic move.