Shouldn't this be called before registering the termination callback?