Refactor readline require and close the prompt before invoking the callback.