as per @graphaelli's suggestion, move error check above cleanup (#315)
as per @graphaelli's suggestion, move error check above cleanup (#315)

closes #315

beniwohli/apm-agent-python,beniwohli/apm-agent-python,beniwohli/apm-agent-python,beniwohli/apm-agent-python