Fix for internal services so that the terminate function is always called.