If a Legendary Pirate loses all their stamina whilst defending your island, they just get exhausted and stay that way until you make them Rest. I presume the bug here is that Legendary Pirates automatically start their Resting period after losing all their stamina in battle.
Nope, not a bug - you have to manually tell them to get some rest, just as if they'd become exhausted during an attack.
If you have an exhausted Legendary Pirate after a battle, the re-hire button text changes to say that you'll also be putting your Legendary into Recovery mode (hence the gem cost on that re-hire also including the cost of instantly resting the LP) - it's not auto resting, as you're still manually choosing to put your LP into Recovery.