Fixed bug closing the system file down cleanly on shutdown