Fix out-of-memory with doCommand() in batch mode

WindowManager's tempImageMap could still hold temporary images after
the batch mode was canceled. Avoid that by releasing temporary images
at the end of the thread.

This fixes the issue reported by Hans Wurscht.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>