Explicitly remove DB session for periodic administrative jobs

With Flask-SQLAlchemy before 0.16, or with Flask before 0.7, database
session is removed in app.after_request hook, which is not run
when we use test request context, so database sessions may leak.
To avoid leaks we remove sessions explicitly after each run of
any periodic administrative job.

Change-Id: Ib39b9b2b94482467c487f96cd0dbae64512d87c2