Add time limit on shutdown and stop

Add time limit on shutdown and stop.