Fixed memory leak

Not closing scanners causes memory leaks, and thus is now fixed