check handle validity when closing a file

This eliminates an assertion under Windows that occurs when an archive cannot be
opened.