I don't have the answers... but I guess he is going through the maturing process and may be deciding to bond with you and doesn't like those who take your attention - I imagine/hope your daughter does take your attention!
I think Julie is probably right, your daughter should try to be the main person to interact with him for a bit.
Are you sure he is a he?
I hope he doesn't do that again and that you manage to help him sort out his behaviour... it's very scary when your birds do that.
Other than that, does he have a routine for when he is out of the cage and when he goes to sleep? Is he getting enough sleep? Could it be he wanted to go to bed?
Regards
Ellie.