If the creature it lives inside is killed, it’ll almost certainly die too.
J.K. Rowling answers a similar question, when she’s asked if Harry could die of something “mundane” with the piece of soul in him. She says that he’d have to die to get rid of the piece of soul, which also indicates dying would be enough to get rid of it, presumably however it happens.
SU: So, can I ask this? This is kind of a random question, but if Harry had this Horcrux in him, sort of, would he actually have died, say, when the dragon could have killed him, or when he was falling during Quiddich, or anything? Could he actually have died?
JKR: Well, you’ve got- if his body had been irreparably destroyed. (SU: Yeah) He has to die to get rid of that piece of soul. His body has got to be irreparably damaged. So a lot of people asked, and I think I’ve answered this since, but a lot of people immediately said, having finished Hallows, (gasps) “But then, that means in Chamber of Secrets, when he was pierced by the basilisk…” (SU: Oh, right) but no, no, no, no, he didn’t die! He didn’t die. (JN: Yeah) That was stated right in the beginning with the Horcrux, the receptacle has got to be destroyed. His body wasn’t destroyed! He got a bit poisoned, and then he got the antidote, immediately. So that’s not going to drive out this piece of soul. Sorry if I sound frustrated, but occasionally…
- PotterCast (Dec 23, 2007)
Although Nagini is an intentionally made Horcrux and therefore different than Harry, it’s likely that this is the case for any living Horcrux. The way to destroy a Horcrux is by putting it beyond magical repair, so that the Horcrux can’t just repair itself. Once this is done, the piece of soul is destroyed.
“It doesn’t have to be a Basilisk fang,’ said Hermione patiently. ‘It has to be something so destructive that the Horcrux can’t repair itself.”
- Harry Potter and the Deathly Hallows, Chapter 6 (The Ghoul in Pyjamas)
However, it doesn’t have to be destroyed completely; the stone in the ring was just cracked, for example. It was still wearable, as Dumbledore wore it, and the Resurrection Stone in it still worked. The diary was stabbed, but not entirely destroyed - it was whole enough for Harry to put a sock in. The important thing is that some amount of damage is done that can’t be repaired magically.
“Sitting on one of the little spindle-legged tables that supported so many frail-looking silver instruments was an ugly gold ring set with a large, cracked black stone.”
- Harry Potter and the Half-Blood Prince, Chapter 10 (The House of Gaunt)
It doesn’t have to be completely destroyed, just damaged in a way that can’t be magically repaired (so it can’t just repair itself). For a living Horcrux, dying would be putting it beyond magical repair, whatever the manner of death is, since magic can’t bring the dead back to life. As Pryftan mentioned in the comments, the Dark Lord thought it was necessary to protect Nagini from death, and he wasn’t going to be expecting the Sword of Gryffindor imbued with basilisk venom.
“It is the only way, Nagini,’ he whispered, and he looked round, and there was the great, thick snake, now suspended in mid-air, twisting gracefully within the enchanted, protected space he had made for her, a starry, transparent sphere somewhere between glittering cage and tank.”
- Harry Potter and the Deathly Hallows, Chapter 32 (The Elder Wand)
The Dark Lord considered it possible enough that someone could kill Nagini that it was worth protection against, even though it meant no longer being able to use her as a weapon.