Refactor peer disconnect code into single func.