Wrap (un)index_webapps in post-request tasks (bug 987927)

This is the 2nd part, wrapping the indexing calls so they happen after `request_finished`. This also removes some unused code in `lib.es`.