Making terminate call consistent for gpu/non-gpu