It depends on the portal if it's even allowed, but in general it's up to the DM
The DMG has a section on Planar Portals which defines the game term portal (emphasis mine)
“Portal” is a general term for a stationary interplanar connection that links a specific location on one plane to a specific location on another. Some portals function like doorways, appearing as a clear window or a fog-shrouded passage, and interplanar travel is as simple as stepping through the doorway. Other portals are locations — circles of standing stones, soaring towers, sailing ships, or even whole towns — that exist in multiple planes at once or flicker from one plane to another. Some are vortices, joining an Elemental Plane with a very similar location on the Material Plane, such as the heart of a volcano (leading to the Plane of Fire) or the depths of the ocean (to the Plane of Water).
So, for at least some portals they function like a doorway. A plain reading of this would thus permit items and creatures, in general, being part way through a portal.
The rules are silent on what happens if something is partway through a general portal when it closes. As a result it's up to the DM.
Not all portals, however allow this
Specific portals have more restrictive text, or at least a more restrictive interpretation is possible, such as the Gate spell:
The portal has a front and a back on each plane where it appears. Travel through the portal is possible only by moving through its front. Anything that does so is instantly transported to the other plane, appearing in the unoccupied space nearest to the portal.
A fair reading of this could be that anything that enters the portal even a little bit is "pulled through" and transported to the other side. This reading would preclude being "part-way" through a portal.
If you take this reading, then the answer to your question for Gate is nothing because it's not possible.
A different reading would could be similar to the doorway interpretation, and that creatures and objects pass through it gradually. Under this interpretation each part of the creature or object is magically teleported to the other side in a smooth and continuous manner, with the magic making sure the place the creature/object is appearing on the other side is unoccupied.
If you take this interpretation then again it's up to the DM.
What would you rule as a DM?
Personally, in my game, if a player was intentionally holding either a part of themselves or an object through a portal to "see what happened", whatever was through the portal would be chopped in twain where the portal bisected it.
If I was feeling generous or we had a discussion out of character at the table, and someone in the group was uncomfortable with that ruling, I'd rule that the object/creature is shoved to whichever side of the portal the majority of the creature/object was.
If on the other-hand a player wanted to try force an enemy creature to be bisected by a closing portal, I would pause the game as discuss it at the table to make sure everyone at the table was comfortable with it. I would also explain that doing something like this meant it could be used against the PCs as well. I would also discuss the introduction of the lingering injuries and system shock rules. Finally I would make it clear that the alignment of the character in question could change, as to hold a creature in order for this to occur requires a level of control over that creature that the creature is effectively subdued. Treating a creature you have subdued in this way is not an act of a "good" creature.