<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def _stopHeartbeatWithReason(self, reason=DISCONNECT.GO_AWAY):
        '''We lost our connection - stop our heartbeat.  This runs when the
        protocol wants a disconnection.

        This redundant output ensures that the heartbeater stops
        immediately after the connection is lost.  Twisted will call
        connectionLost after loseConnection, but between the two the
        heartbeat-writing callback may run, after the transport's been
        lost.  Relying on connectionLost to cancel our
        callback thus creates a race condition.

        '''
        self.heartbeater.stop()
        self.heartbeater = None