Explicit checking before exiting. Fixes #12