quit() and end() tests and fix, closes #2