more robust stop script