Allow service termination function to be configured