close mysql connection when indexing context is destroyed