need a better way to do graceful exit