Now properly closes scanner