Add code to close/reopen connection part of the time. #710