sqlite: prevent reentrant session.close()