enhanced stop function to call http or https as url for api shutdown