When they type quit, they actually type "enter" after the four letters; that becomes part of the string. When the string is converted to a number (for the == compares) the trailing newline (like all whitespace) is silently ignored, but eq is tripped up by it.
Traditionally, one handles this by saying:
while (my $guess = <STDIN>) {
chomp($guess);
...
See
chomp.