added server closing support