OTA System.updatesPending()

When OTA updates are pending. What type of code would be best used to make the OTA update as reliable as possible?

So once (System.updatesPending() == true) what type of while loop or control loop could I use to make sure that once the update starts, the remaining code will not impede the update.

like something below??

while (System.updatesPending()) {