Fixes problem with the parameters of the authenticate function.
Moved the QUIT command to a function in functions.php