If mount it using fstab - I recommend switching to a set of systemd mount units as described in Samba mount unit example
Be sure to understand the unit file’s naming convention also described in the topic at Important naming convention
The described mounting automagically disconnects the device when the path is not accessed within the configured TimeoutIdleSec.