popen4: only close spawn file descriptors if they exist

This updates the `popen4` method to only close its file descriptors
in its `ensure` if the descriptors exist (are not `nil`).

This allows for any `Too many open files (Errno::EMFILE)` exceptions
to be raised.  Without this change, the above exception is "swallowed"
by an `undefined method `close' for nil:NilClass (NoMethodError)`
that is raised by the ensure code.