Determine if in Teams or Sharepoint

Is there a way to determine if a Form is opened within the Sharepoint Environment versus Teams? My end objective is to have Project Teams work within Microsoft Teams. The channels would be related to a specific list item, so I would create a tab linked to the EditForm of the item. I have the save button set to not close the form. However, the Close button will create some confusion in the Teams environment because it will bring the user back to the list. An option for a workaround would be to create another form set and hide the close button for the Teams form but this will require additional work as I am still developing and improving the forms based on user input. This is all still fresh for my company. Ideally I would like to code it into the default form.

Dear @cwalter2,
Not sure, but maybe you can check window.location.href to get the URL of the current page?

Thanks you it worked perfectly. I added the following code:
var envTest = window.location.href;
if (envTest.includes('env=TeamsPageWebView')) {
fd.toolbar.buttons[1].style = "display: none;";
$('.checkTeams').hide();
}