Properly stop the tracker before terminating.
Log API errors