make sure connection is closed in check()

fixes GH-1