For two reasons...
He's actually about to take Dany's hand but sees that the party is still being attacked at close quarters.
He turns and defends the other member of the party so that they have time to climb on the dragon and, importantly, complete the mission by taking the wight with them.
Then things get away from him..
Once he's involved with defending the party he goes into a kind of berserker mode.. defending the party but just despatching the dead without really giving thought to the consequences.
He's moving further and further away from the party... and towards the Night King...his principal enemy. You can see the expression on his face is one of defiance and anger.
Only when the Night King threatens to take down the dragon Dany is riding does he come to his senses.
Now the party is really at risk of not escaping and, thus, failing in their mission...so he tells them to go but is taken down and pushed under the ice as he attempts to re-join the party.