try
    Screen('OpenWindow', 0);
    t0 = GetSecs;
    WaitSecs(5);
    t1 = GetSecs;
    Screen('CloseAll');
    t_elapsed = t1 - t0;
catch
    Screen('CloseAll')
    rethrow(lasterror)
end