add graceful shutdown middleware
fix q test