Close all connections when tearing down the app and add logs