Glass on Napoleonic warships

All the Napoleonic era warships seem to have huge quantities of glass in their sterns. Would this have been removed prior to battle?

No. The glass was in the sterns to give the officers, whose quarters where also located there, some measure of luxury.

Prior to combat, a great deal was changed inside the ship - all of the walls on a gun deck were dismantled and all furniture stowed away - but they didn’t take apart the windows chiefly because they were not made to take down.

During combat, it was recognized that the stern was the most vunerable part of the ship and foes would manouver in a manner to try and pass their sides sides (where the cannon pointed) across the opposing ships vunerable stern (and bow). By doing this (called ‘raking’ fire) their cannonballs were often able to traverse the entire length of the ships open deck instead of the shorter distance across it.
Nelson’s ‘crossing of the line’ took advantage of this.

Of course ships would also try to avoid being put in the vunerable position.

Was it poor design to have open windows on a warship? Of course. However besides the loss of the windows from a hit on the stern, I doubt the shards of glass would be much more dangerous than the splinters of wood - which was always a sailer’s most likely way to be injured/killed. But the real reason is a ship typically didn’t get into heavy combat enough to warrant a change that would make an officer’s existense more wretched for want of a window.