Calling done() when all jobs are finished

This PR is same as #41 but it's rebased with 0.4.0 version, so pulling it in should be straight forward.