cleanly exits upon errors