You can use a Box Collider to define the volume where particles are drawn and tell the Particle System to destroy particles lying outside it.
The Particle System features the Triggers module that lets you define particle behaviour when they interact with Colliders in the Scene. You can use it to destroy particles when they move outside a Collider of choice (I suggest a Box Collider since you are generating particles from a rectangle):
- Add a Box Collider Component to the Particle System GameObject.
- Alternatively: create a Box GameObject as a child of the Particle System GameObject. (Parenting GameObjects allows you to move the System around the Scene.)
- In the Particle System, enable the Triggers module.
- Add a new trigger.
- Drag and drop the Box Collider Component onto the trigger empty slot.
- Alternatively: drag and drop the GameObject owning the Box Collider from the Hierarchy (be it a child GameObject or the Particle System GameObject itself).
- Set the Outside trigger condition to "Kill" and the remaining conditions to "Ignore".
You can now define a dedicated shape for generating particles and a different one for containing them. In your case, you may want to place the rectangle (Particle System's Shape module) so that it overlaps the top face of your Box Collider.
Here's a quick snapshot from the Inspector:
EDIT: If you want to resize the container volume without manually adjusting the shapes' position, you can use an Editor script to automatically update the emission shape's position based on the container volume size.