Check whether there are context items when writing the task time summary. It was causing errors like:
$currentContext = $psake.context.Peek() +  ~~~ [<<==>>] Exception: Exception calling "Peek" with "0" argument(s): "Stack empty." --> Stack empty.