I'm wondering about this too! Sad to see there aren't any replies.
I did something similar -- parts not included for walking in the navmesh, like static objects in the scene, would be a problem when my agent would get to them and just continue to walk and walk.. and walk. Maybe this can be of use to you.
For now, I worked something up so that my agent walks as close as it can to an area that's not on the navmesh then stops and I clear the path.
I put these in an if statement in my update and check to see if the destination has been reached. Checking if the type of path is partial (I think: part of it is unreachable) and then if we have a path to the desired position (it seems to be true if we can do any more movement, then false when we reach the block).
agent.pathStatus == NavMeshPathStatus.PathPartial && !agent.hasPath
This way, even when I click on something that's not walkable, like inside a block, it walks as close as it can and stops. Then I have it abandon the path.

Here's what I'm using, until I can find something better. It checks if the agent has reached the destination. There's also my code in that block to see if the agent has reached the destination when the path isn't partial so that I can control my walking and idle animations. isMoving is set when a destination is set for the agent. It's kind of a mouthful. The stuff relevant to the partial path is above, you can check it out in use below if you're interested.
if (isMoving && !agent.pathPending)
{
if ((agent.pathStatus == NavMeshPathStatus.PathPartial && !agent.hasPath) ||
((Vector3.Distance(agent.destination, agent.transform.position) <= agent.stoppingDistance) &&
(!agent.hasPath || agent.velocity.sqrMagnitude == 0f)))
{
Debug.Log("reached destination");
isMoving = false;
anim.SetBool("IsRunning", isMoving);
agent.ResetPath();
}
}
I'm still new to unity, so I'm not sure if this is the optimal way that this could be done. If anyone has input, I'd be happy to hear it!
EDIT:
I was messing around a bit (something smelled off...) and I think some of that code was redundant. I tested it under the same conditions as the other code and I get the same results with just:
if (isMoving && !agent.pathPending && !agent.hasPath)
{
Debug.Log("reached destination");
isMoving = false;
anim.SetBool("IsRunning", isMoving);
agent.ResetPath();
}