add graceful close