I don't think this is a glitch. It's probably getting mad at you and trying to leave. If you're unable to do anything at all, you may want to press the reset button and select "download" in order to try and help your Tama.
If you're able to press buttons right now, then open the stats screen and find out what your Tamagotchi needs. It might have very low happiness or be very hungry. If so, feed it and play some music games.
In the future, if it is calling for attention, you might want to give it what it needs earlier on.
Some questions to make the question a little clearer: How old is your Tamagotchi? What character is it? Have you fed it recently?