Close the aceperl connection at earliest opportunity, so that the script finishes cleanly