There exist multiple previous discussions on this. But, here is a simple piece of code that will do what you want:
Names Default To Here( 1 );
For( i = N Table(), i >= 1, i--,
If( N Rows( Data Table( i ) ) == 0,
Close( Data Table( i ), nosave )
)
);
Jim