title: node.js Winston - how to safely drain a logger
body: <p>I have experimented with instantiating and closing winston loggers as (half) described on <a href="https://github.com/flatiron/winston#instantiating-your-own-logger" rel="noreferrer">https://github.com/flatiron/winston#instantiating-your-own-logger</a>, to no avail. I run into trouble closing file transports of Winston's - walking through it's source code, I found that the proper way to close off a logger would seem to be the <code>close</code> method. I expected this to take care of closing the transport file used by the logger - however that turned out to be not so. </p>
  
  <p>Varying in frequency according to node.js server load, winston would still hold on to many transport files, infinitely long after the <code>close</code> method had been called for them, indefinitely long after no new writes were being initiated to them. I observed that through the node.js process file descriptors table (<code>lsof -p</code>). Even though <code>close</code> has been called for a Winston logger, it would indefinitely keep the file descriptor of the log file "in use", i.e. the log file never gets really closed. Thus leaking file descriptors and eventually making the node.js process bump into the ulimit (-n) limit after my application has been up for long.</p>
  
  <p>Should there be a specific programming pattern for draining a Winston logger such that it can be eventually closed? </p>