Finish as quickly as possible after using the required number of bits.

This pull request brings the Perl version up to date with the Java version by ending the poem as quickly as possible once the required number of bits have been used.