close mongo and redis properly