Implement wait function to wait for a qsubbed job to finish.