code: public void stop() {
  
  		this.logger.info( "Agent '" + getAgentId() + "' is about to be stopped." );
  
  		// Stop the timer
  		if( this.heartBeatTimer != null ) {
  			this.heartBeatTimer.cancel();
  			this.heartBeatTimer = null;
  		}
  
  		// Prevent NPE for successive calls to #stop()
  		if( this.messagingClient == null )
  			return;
  
  		// Send a last message to the DM
  		try {
  			if( this.messagingClient.isConnected()) {
  				this.messagingClient.sendMessageToTheDm( new MsgNotifMachineDown( this.applicationName, this.scopedInstancePath ));
  				this.logger.fine( "Agent " + getAgentId() + " notified the DM it was about to stop." );
  			}
  
  		} catch( IOException e ) {
  			this.logger.warning( e.getMessage());
  			Utils.logException( this.logger, e );
  		}
  
  		// Close the connection
  		try {
  			this.messagingClient.getMessageProcessor().stopProcessor();
  			this.messagingClient.getMessageProcessor().interrupt();
  			this.messagingClient.closeConnection();
  
  		} catch( IOException e ) {
  			this.logger.warning( e.getMessage());
  			Utils.logException( this.logger, e );
  		}
  
  		this.logger.info( "Agent '" + getAgentId() + "' was stopped." );
  	}
docs: Stops the agent.
  <p>
  It is invoked by iPojo when an instance becomes INVALID.
  </p>