Make AI follow you up to a certain point

I made a script in which an enemy follows the player around. I have a problem though, since when the enemy reaches the player, it starts vibrating and “phases” in and out of the player, and I actually just want for the enemy to follow the player up to a certain radius. Is this possible given my current code?

void Start()
{
    rb = this.GetComponent<Rigidbody2D>();
}

void Update()
{
    Vector3 direction = player.position - transform.position;
    direction.Normalize();
    movement = direction;
}

private void FixedUpdate()
{
    moveCharacter(movement);
}

void moveCharacter(Vector2 direction)
{
    rb.MovePosition((Vector2)transform.position + (direction * GoblinMoveSpeed * Time.deltaTime));
}

}

There is an offset field in the NavMeshAgent component in the inspector. Just set this to a higher value and the agent will stop before phasing into the target.