Updated detection of mysql connection and closing.
Merge branch 'develop'