@Override
    public void close() throws IOException {
        synchronized (this) {
            if (state == SystemState.CLOSED)
                throw new IOException("Storage was closed earlier.");
            
            boolean needGCrun = false;
            try {
                if (randomAccessFile != null) {
                    if (fileChannel != null) {
                        if (fatZone != null) {
                            markDiskStateActual();
                            force();
                            if (fatZone instanceof DirectBuffer) {
                                // That is bad, but it is the only available solution
                                // http://stackoverflow.com/questions/2972986/how-to-unmap-a-file-from-memory-mapped-using-filechannel-in-java
                                sun.misc.Cleaner cleaner = ((DirectBuffer)fatZone).cleaner();
                                // critical point: fatZone have to be [null] ASAP to avoid 
                                // finalizer call with double free and JVM crash
                                fatZone = null;
                                cleaner.clean();
                            } else {
                                fatZone = null;
                                LogError("Not Oracle implementation for memory-mapped file."
                                       + "We can get a problem. Trying direct GC call.");
                            }
                            needGCrun = true;
                        }
                        fileChannel.close();
                    }
                    randomAccessFile.close();
                }
            } finally {
                // RIP
                state = SystemState.CLOSED;
                if (needGCrun)
                    System.gc();
            }
        }
    }