don't call #close if we have no filehandle

For some reason the #open call is failing on our CI server, but we lose
the stacktrace due to the #close call failing on a nil object