Automatic Identification System :
The AIS is a maritime transponder, used in VHF frequency for identification of ships, navigation marks and coastal stations for safety of navigation
AISs are designed to be capable of providing information about the ship to other ships and to coastal authorities automatically.
The information published on the open source websites such as Marine Traffic or Vessel Finder rely on the coastal relays, which get the AIS signal from the ships by VHF. The VHF frequencies have a limited range of 30 to 50 miles. If a ship is more than 30-50 miles from a shore-based relay antenna, the ship is not visible on the websites anymore, but the AIS is still ON and visible by all stations located 30-50 miles around the ship.
AIS must be activated at any time, unless the master of the ship decides to switch-off for a minimum period of time the transponder for exceptional security reasons. In such a case, the Master must report on the bridge logbook the duration and the reason of this deactivation.
More technical information here : https://www.navcen.uscg.gov/?pageName=AISworks
More information about the AIS regulation here : http://www.imo.org/en/OurWork/Safety/Navigation/Documents/227.pdf