You could skim this guide for help, especially Step #3.
What I do is wait about 13 seconds (use a clock, not yourself counting), and then watch the lights on the router. The light should flicker a bit in the beginning, but when it blinks rapidly at around 17 seconds in, this is when wifi is trying to send your Pokemon, so that's when you turn off your game.