Move the metrics mutex into the ifdef MBED_STACK_STATS_ENABLED since
it is not used ouside of it. This fixes the warning:
[Warning] greentea_metrics.cpp@37,28: 'mutex' defined but not used [-Wunused-variable]
Update greentea to report thread information when a thread exits or
is terminated and when testing completes. Also move metrics into
a dedicated greentea file.