Add key validation

Add a 'fatal' function to print a message to stderr and exit with error code 1