work on graceful close