Use an on finish handler to exit the server. Added secret.