Graceful termination fixes