Each ability will specify when it ends.
There is no rule that covers all polymorph abilities. Rather, each ability describes when the effects end.
For example, the Aerial Form spell (Core Rulebook, pg. 316) has a duration of 1 minute. It's only traits are polymorph and transmutation, neither of which influence when the effects end. If you use this spell to polymorph into a bird, which is promptly killed by a raptor, then you are dead and a bird until the 1 minute duration is up.
Some abilities include this in the outcomes of the ability. Baleful Polymorph lasts:
- On a success, the target is polymorphed and sickened 1. When it recovers from sickened, the condition ends.
- On a failure, the target is polymorphed for 1 minute or until it spends a turn and passes a will save.
- On a critical failure, it lasts forever.
One trait that may be relavent is concentrate. The barbarian's Dragon Transformation feat (pg. 93) includes both polymorph and concentrate traits. The description of concentrate says:
An action with this trait requires a degree of mental concentration and discipline.
To my knowledge, there is no rule that says the effects of an ability with the concentrate trait disappear when the user is unconscious or dead. On the other hand, the abilities do require mental concentration which may be impossible in those cases. Reasonable GMs may differ on how they interpret these facts.
The Dandasuka
So how about that dandasuka? It's Change Shape ability doesn't have any explicit end. Additionally, the Bestiary entry for Change Shape says:
The monster changes its shape indefinitely. It can use this action again to return to its natural shape or adopt a new shape.
So for the Dandasuka, it will stay in its polymorphed shape until it decides otherwise.