Fix double close bug when using serveFile api