add timeout for blocking and graceful shutdown