Fix #12811 by closing files promptly in tabnanny.check. Patch by Anthony Briggs.
diff --git a/Lib/tabnanny.py b/Lib/tabnanny.py
index 46f8163..4a54f89 100755
--- a/Lib/tabnanny.py
+++ b/Lib/tabnanny.py
@@ -126,6 +126,9 @@
             else: print(file, badline, repr(line))
         return
 
+    finally:
+        f.close()
+
     if verbose:
         print("%r: Clean bill of health." % (file,))
 
diff --git a/Misc/ACKS b/Misc/ACKS
index 2b6104f..062a77a 100644
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -121,6 +121,7 @@
 Brian Brazil
 Dave Brennan
 Tom Bridgman
+Anthony Briggs
 Tobias Brink
 Richard Brodie
 Michael Broghton
diff --git a/Misc/NEWS b/Misc/NEWS
index ab70dfd..eeb0d71 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -265,6 +265,9 @@
 Library
 -------
 
+- Issue #12811: tabnanny.check() now promptly closes checked files. Patch by
+  Anthony Briggs.
+
 - Issue #6560: The sendmsg/recvmsg API is now exposed by the socket module
   when provided by the underlying platform, supporting processing of
   ancillary data in pure Python code.