how much time is “after time” please? I have a “dead” sessions which are taking more than 7 days. It is possible to configure the idle timeout for SSH/webfig session?
Use IP > Firewall > Connections [Tracking] button, and set TCP Established timeout accordingly.
This will affect to all connections to/from/traversing this router; unless remote browser/ssh client sends keepalive packets, it should do.
Otherwise you’ll need to make an script that monitor this (/user active), and by using their address and dst port = webfig or ssh remove their connections on IP > Firewall > Connections.