widget: Do not leave behind a zombie child when closing a terminal

https://bugzilla.gnome.org/show_bug.cgi?id=740929
(cherry picked from commit 31b150146189b49fadd126edc1c373ada234c865)
widget: Reap only when a child is present

https://bugzilla.gnome.org/show_bug.cgi?id=740929
(cherry picked from commit 5f19e0b08cb06c76d989592e1a859ac3a23b8b4b)