Wait for the window to have loaded