Completing switch over to closing api connection with exit() in tasks