Wait until rendering is finished

Yes, seems like it was useful for other scenarios, too: