refactor(main): close peer server first