Fix simulation shutdown (issue #22).