Hello Samira,
Another way is:
timeSinceSessionStart = now*100000 - BpodSystem.ProtocolStartTime;
This will return the time in seconds since the protocol started. Note that this time is measured by MATLAB, not the state machine clock. The two clocks will drift slightly, but if the point is to automate session-end, it should work.
This way of doing it will allow you to use tic/toc inside your code for debugging if necessary.
-Josh