Hi Giulio,
The reason why you have those openings instead of a closed solid, is because your mesh is overlapping it's self in the corners. I would suggest breaking it up in two parts; use a a extruded polygon for the top section use subdivision for what's underneath. Then, you can convert the Sub to a mesh and do a solid add with the polygon. From this point everything should subtract as expected.