Wait until all outstanding requests have been processed, with a 1 second sleep in between checks

Also add a timeout mechanism to wait no longer than 60 seconds for all outstanding requests to complete

Also flush transport client before shutdown is called