How to close mongodb idle connection(active: false)?
This can be avoided by setting up the maxIdleTimeMS parameter of Connection Pool Options


  This maxIdleTimeMS parameter sets the maximum number of milliseconds
  that a connection can remain idle in the pool before being removed and
  closed.


Set this parameter as per your requirement. So the idle connections will be closed once the time limit exceeds.