Add graceful termination