The solution is mostly not to go public. Valve is a good example of this.
Do well enough that you don't need outside investors, or if you take on outside investors select them carefully and ensure they don't expect an IPO.