function onFinished(msg, listener) {
  if (isFinished(msg) !== false) {
    defer(listener)
    return msg
  }

  // attach the listener to the message
  attachListener(msg, listener)

  return msg
}
Invoke callback when the response has finished, useful for
cleaning up resources afterwards.

@param {object} msg
@param {function} listener
@return {object}
@api public