Added elegant exit routine