Added graceful termination