# Wait for frames queue is empty (all frames are send to renderer)
frames.join()

# Wait local renderer to finish tasks
if localRendering:
	localrenderer.join()

# wait for the remote renderers to finish and ask the listener to stop
rt = listener.getRemotethreads();
listener.requestStop()
for r in rt:
	debug('waiting for end of thread %s'%r.getName())
	r.join()

# wait for the listener to stop (but not forever)
listener.join(20.0)

# display some statistics, to see if it was worth the effort
endtime = time.time()
partlist = NetworkRender.displaystats(stats, parts * parts, starttime, endtime)

# try to merge to parts and show the result in the image editor
ext = '.' + configurer.getFileExtension(imageType)
fd,name = mkstemp(suffix = ext)
os.close(fd)
NetworkRender.collate(partlist,name)
im = Image.Load(name)
im.makeCurrent()

Draw.PupMenu("Still rendering completed%t|Ok")