You can use below logic to stop your test while getting HTTP 500 error:
int HttpRetCode;
lr_start_transaction("My_Trans");
web_url("my_home",
"URL=http://my_home",
"TargetFrame=_TOP",
LAST );
HttpRetCode = web_get_int_property(HTTP_INFO_RETURN_CODE);
if (HttpRetCode == 500)
{
lr_end_transaction("My_Trans", LR_FAIL );
vuser_end();
}
else
lr_end_transaction("My_Trans", LR_PASS);