Just be very careful with closing handles; it's even more dangerous than you'd think, because of handle recycling - if you close the file handle, and the program opens something else, that original file handle you closed may be reused for that "something else." And now guess what happens if the program continues, thinking it is working on the file (whose handle you closed), when in fact that file handle is now pointing to something else.
see Raymond Chen's post on this topic
Suppose a search index service has a file open for indexing but has
gotten stuck temporarily and you want to delete the file, so you
(unwisely) force the handle closed. The search index service opens its
log file in order to record some information, and the handle to the
deleted file is recycled as the handle to the log file. The stuck
operation finally completes, and the search index service finally gets
around to closing that handle it had open, but it ends up unwittingly
closing the log file handle.
The search index service opens another
file, say a configuration file for writing so it can update some
persistent state. The handle for the log file gets recycled as the
handle for the configuration file. The search index service wants to
log some information, so it writes to its log file. Unfortunately, the
log file handle was closed and the handle reused for its configuration
file. The logged information goes into the configuration file,
Meanwhile, another handle you forced closed was reused
as a mutex handle, which is used to help prevent data from being
corrupted. When the original file handle is closed, the mutex handle
is closed and the protections against data corruption are lost. The
longer the service runs, the more corrupted its indexes become.
Eventually, somebody notices the index is returning incorrect results.
And when you try to restart the service, it fails because its
configuration files have been corrupted.
You report the problem to the
company that makes the search index service and they determine that
the index has been corrupted, the log file has mysteriously stopped
logging, and the configuration file was overwritten with garbage. Some
poor technician is assigned the hopeless task of figuring out why the
service corrupts its indexes and configuration files, unaware that the
source of the corruption is that you forced a handle closed.