Use wait() instead of poll() during subprocess shutdown

There is a race condition between the output pipes being closed by the
child and python updating the returncode on the Popen object.  Let's use
wait() instead of poll() to avoid this and not get a called process
failure.

Should fix #88