Added cleanup function for ack_thread.