Wait for all pending promises to be finished