function makeCloseable(server) {
	/** @type {Set<import('net').Socket>} */
	const sockets = new Set();
	let listened = false;

	server.on('connection', s => {
		sockets.add(s);
		s.on('close', () => sockets.delete(s));
	});

	server.once('listening', () => (listened = true));

	return async () => {
		sockets.forEach(s => s.destroy());
		if (!listened) return;
		await new Promise((resolve, reject) => {
			server.close(err => (err ? reject(err) : resolve()));
		});
	};
}
Close all open connections to a server. Adapted from
https://github.com/vitejs/vite/blob/352cd397d8c9d2849690e3af0e84b00c6016b987/packages/vite/src/node/server/index.ts#L628
@param {import("http").Server | import("http2").Http2SecureServer} server
@returns