Fix "finish recursion" condition by explicitly checking for undefined. Fixes #5