improving graceful shutdown
now tests pass