The Rema in Siman 316 brings down the Halacha that it is prohibited to close a box or container in which there is a bug. Doing so constitutes the Melacha of Saad (trapping). This holds true even if the bug is not the type which is usually trapped, and the violation is only Dírabanan (rabbinic).
Interestingly, Maran does not bring this Halacha in Shulhan Aruch. This is especially puzzling since he does present this Halacha in his Bet Yosef, in the name of its source, the Sefer HaTerumah, and comments "Mi Yakel Kínegdo?"-Who can be lenient against his ruling?
The Poskim explain why Maran didnít bring this Halacha in Shulhan Aruch based on a general Halachic principle of Maran. In this case, the person closing the box does not intend to trap the bug; he just wants the box closed and the bug becomes trapped unintentionally, albeit inevitably. This is known as "Pesik Reshe Dílo Nicha Leh"-an action whose inevitable outcome is a Melacha, but that outcome was not the purpose of the action and the person has no interest or benefit from that outcome. Hacham Ovadia (Yabia Omer 4:15, Ohr Yisrael p. 92) holds that Maranís position on such cases was to be lenient when the Melacha involved is Mídrabanan (rabbinic). This could explain why Maran didnít bring this prohibition, since the Melacha involved is only Mídrabanan, as the case is referring to bugs that are not usually trapped. It goes without saying that if one is not sure whether there is even a bug in the box to begin with, there is no problem closing the box.
One may close a box containing a type of bug that is not usually trapped, if his intent is merely to seal the box and not to trap the bug.