You are asking two different questions. To close the database with the
form, just include code in the form's close event. That does not prevent
the user from moving that form to the side or minimizing it and seeing your
other objects.
To truly prevent the users from getting to your tables and queries, you'd
need to implement User-Level Security and take away their access from those
objects. You'd need to base your forms and reports on queries set to run
with owner's permission.
To prevent the database window from being seen when opened, you'd need to
change the setting in your startup options and not allow the shift bypass
key. You'd also want to remove menus and toolbars. To make sure your form
starts with the database, you need to put it in the startup options. You
might also set it as pop-up and modal.