progress dialog keeps on spining after inserting data

i am just creating a simple login signup module. i have written the following code it inserts data but the progress dialog keeps on spining and it never stops but if i check my database the data is there inserted all correctly i am using volley liabrary. i am a biggener on android volley plz tell me where i am going wrong.

My Registration page is:

 public class registration extends AppCompatActivity {
EditText Name,Email,Username,Password;
ProgressDialog dialog;
ProgressBar progressBar;
String Reg_url="------";

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_registration);
    Name=(EditText)findViewById(R.id.nametext);
    Email=(EditText)findViewById(R.id.email);
    Username=(EditText)findViewById(R.id.Username);
    Password=(EditText)findViewById(R.id.pass);
    dialog=new ProgressDialog(this);
    dialog.setTitle("Loading");
    dialog.setMessage("Please Wait a Momment");

    dialog.setCancelable(false);
}
public void SignUp(View view)
{
    if(TextUtils.isEmpty(Name.getText().toString()))
    {
        Name.setError("At least 5 charachters");
    }
    else if(TextUtils.isEmpty(Email.getText().toString()))
    {
        Email.setError("Enter a Valid Email");
    }
   else if(TextUtils.isEmpty(Username.getText().toString()))
    {
        Username.setError("At least 5 charachters");
    }
    else if(TextUtils.isEmpty(Password.getText().toString()))
    {
        Password.setError("At least 5 charachters");
    }
    else
    {
        dialog.show();
        StringRequest stringRequest=new StringRequest(Request.Method.POST, Reg_url,
                new Response.Listener<String>() {
                    @Override
                    public void onResponse(String response) {

                        try {
                            JSONArray jsonArray=new JSONArray(response);
                            JSONObject jsonObject=jsonArray.getJSONObject(0);
                            dialog.dismiss();
                            finish();
                            startActivity(new Intent(registration.this,MainActivity.class));
                        } catch (JSONException e) {
                            e.printStackTrace();
                        }
                    }
                }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {
                dialog.dismiss();
                Toast.makeText(registration.this,"Connection Failed",Toast.LENGTH_LONG).show();
            }
        }){
            @Override
            protected Map<String, String> getParams() throws AuthFailureError {
                Map<String,String> map=new HashMap<String, String>();
                map.put("name",Name.getText().toString());
                map.put("email",Email.getText().toString());
                map.put("user_name",Username.getText().toString());
                map.put("password",Password.getText().toString());

                return map;
            }
        };
        int socketTimeout= 30000;
        RetryPolicy policy=new DefaultRetryPolicy(socketTimeout,DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT);
        stringRequest.setRetryPolicy(policy);
        RequestQueue requestQueue= Volley.newRequestQueue(this);
        requestQueue.add(stringRequest);
    }

}
}

i have used user permission for internet.
i have volley dependencey volley 1.1.0.
it showes the onerrorresponse correctly but in respone if i would apply a toast that wont show either but data will be inserted.
my php code is:

<?php
require "connect.php";
$name = $_POST["name"];
$email =$_POST["email"];
$user_name =$_POST["user_name"];
$password =$_POST["password"];
$sql = "INSERT INTO `user_info`(`name`, `email`, `user_name`, `password`) VALUES ('$name','$email','$user_name','$password')";
$result = mysqli_query($con,$sql);
mysqli_close($con);
?>

i have searched but was not able to find something if the question is already answered please point me to the way

progress dialog keeps on spining after inserting data